Let make computer ask from youC Input
The solution for previous task is :
The previous program is good, but it would be better if it read in the values from the user instead of using constants.
Try this program instead:
Note that scanf uses the same sort of format string as printf .
Also note the & in front of name , age and income. This is the address operator in C . It returns the address of the variable . You must use the & operator in scanf on any variable.
The scanf function allows you to accept input from standard in, which for us is generally the keyboard.
The simplest application of scanf looks like this:
scanf("%d" , &b);
The program will read in an integer value that the user enters on the keyboard (%d is for integers, as is printf, so b must be declared as an int) and place that value into b.
The scanf function uses the same placeholders as printf:
- int uses %d
- float uses %f
- char uses %c
- character strings (discussed later) use %s
1. Ask user for two number and show them sum of these number
- Learn about getchar() & putchar() functions Here is program to understand it :