C Input Let make computer ask from you

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:

  1. int uses %d
  2. float uses %f
  3. char uses %c
  4. character strings (discussed later) use %s


1. Ask user for two number and show them sum of these number
  1. Learn about getchar() & putchar() functions Here is program to understand it :
(adsbygoogle = window.adsbygoogle || []).push({});