C Programming Tutorial 5, Getting User Input

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

personally I find the "see you guys" bit a little funny because when I heard it what I thought was "c you guys"....anyways I love your videos and I really appreciate your help!THANK YOU! <3

mairooni
Автор

It's because you're only reading in a single character from the console. If you want to read multiple, or a string, then use this code:

char myStr[50];
scanf("%s", myStr);

I'm sure that I cover this in later tutorials though.

iTzAdamX
Автор

It's been a week and im learning more and more every day i thank you sir these are all the ones iv memorized below :D

int main;
int n1 = 5;
int n2 = n1;
int n3 = n1 + n2;
printf("%i", n3);
return 0;

int main;
float f1 = 2.5;
float f2 = 2.5;
float f3 = f1 + f2;
printf("%.0f", f3);
return 0;
 
int main;
char c1 = 'A';
printf("%c", c1); 
return 0;

int main;
int n1 = 0;
printf("Enter first number: ");
scanf("%i", &n1);
int n2 = 0;
printf("Enter second number: ");
scanf("%i", &n2);
printf("The Answer Is %i", n1 + n2);
return 0;

int main;
float f1 = 0;
printf("Enter first number: ");
scanf("%f", &f1);
float f2 = 0;
printf("Enter Second Number: ");
scanf("%f", &f2);
printf("%.1f", f1 + f2);
return 0;

nathanglover
Автор

i like how fast paced yours videos are

ReubMann
Автор

thanx but honestly u moved so fast i have to pause cause i wanna understand what im doing, but your great bro been a lot of help i plan on taking computer science as a major in college so trying to practice certain things now

godsword
Автор

Don't we need a gap before %c? I heard somewhere (and experienced once) that not doing so with break the code.
So code should be something like:
char s;
printf("enter char");
scanf(" %c", &s);
printf("%c", s)
?

johnthesilverwing
Автор

just started your videos and I'ma little curious. Why are you using scanf instead of cin>>? is there a major difference between the two?

Kaneyren
Автор

Interesting. I suggest, however, to make the examples more interesting/usable.

Grkgermn
Автор

are there other ways of making this kind of program cause i had seen other ways of doing this kind of user input 

quiroz
Автор

Might I ask what compiler you use and where I can download it?

rzezzy
Автор

Write( in c language) a function that asks the user
to enter a statement than the program display how many vowels

SH-fpom
Автор

thanks alot for video, , , good job :-)

MrMehran
Автор

what's the purpose of int num = 0 ; in the beginning?

ahmed
Автор

Woah there buddy. You should never use scanf because it doesn't check for overflow and can make your application insecure.

TheKurtPrice
Автор

why when the char code is put after the previous int code, does the program skip the input part? it doesn't have that problem when the char code is first.

jameykelly
Автор

#include <stdio.h>
#include <stdlib.h>
int main()
{
    float num = 0;
    printf("Please enter a number: ");
    scanf("%f", &num);
    float num2 = 0;
    printf("Please enter a second number: ");
    scanf("%f", &num2);
    printf("The sum is: %.2f\n", num + num2);
    printf("The difference is: %.2f\n", num - num2);
    printf("The product is: %.2f\n", num * num2);
    printf("The quotient is: %.2f\n", num / num2);
    return 0;
}
I suck at c....im used to java. I have been coding that for three years. Still used to jframes, event handlers, extension filters, and opengl :(

ryanpvw
Автор

Hey guys how do you effectively get user input on a continuing basis without struggling back and forth with the input buffer?? fflush(stdin) has not worked for me, neither has using scanf(" %c") or "%c\n" . Every time, the input buffer feeds a newline into the program. THe only solution I have found is to use getchar() on Windows 10. Thanks.

EnduranceT
join shbcf.ru