C programming;Lesson 5: Getting keyboard input
To load data from the keyboard, use the scanf function.
The shape of the function is:
scanf ("list_of_formats", list_of_variable_address);
The variable address can be obtained by using the operator & before the variable name, while the variable formats are the same as the case of printing data on the screen.
An example of loading a variable from the keyboard:
int a;
scanf ("%d", &a);
An example of loading multiple keystrokes variables:
int a;
float b;
scanf ("%d%f", &a, &b);
scanf ("%d,%f", &a, &b);
Learn C programming from basics .....
ReplyDeleteBasic C programming examples
C pattern programming examples
C Arrays examples
Loops in C examples
if-else in C with examples
Strings in C with examples