Standard Input
scanf() Function
scanf() function reads data from a standard input device into arguments specified by the format string.
scanf(format string, arguments)
1.
/* Input through the keyboard */
#include <stdio.h>
#include <conio.h>
void main()
{
int x,y,sum;
clrscr();
printf("Enter an Integer:");
scanf("%d",&x);
printf("Enter another:");
scanf("%d",&y);
sum = x + y ;
printf("sum =%d \n",sum);
}
2.
/* Floating point Numbers */
#include <stdio.h>
#include <conio.h>
main()
{
float x,y,sum;
clrscr();
printf("Enter a number:");
scanf("%f",&x);
printf("Enter another:");
scanf("%f",&y);
sum = x + y ;
printf("sum =%.2f \n",sum);
}