C Input Let make computer ask from you

The solution for previous task is :

scanf

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);
1

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

TASKS


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({});
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date(); (function(){ var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0]; s1.async=true; s1.src='https://embed.tawk.to/5bd7b562476c2f239ff683f0/default'; s1.charset='UTF-8'; s1.setAttribute('crossorigin','*'); s0.parentNode.insertBefore(s1,s0); })();
(adsbygoogle = window.adsbygoogle || []).push({});