C Programming-scanf
1
2
What is scanf?
Stands for scan formatted string
Accept character, string and numeric data from the user
using standard input – Keyboard
Scanf also use format specifiers like printf.
For example
%d to accept input of integer type
%c to accept input of character type
%s to accept input of string type
%f to accept input of float type
so on..
Example
int VAR;
scanf(“%d” ,&VAR);
Why &?
Why &?
&VAR
ADDRESS OF VAR
Example
#include<stdio.h>
int main()
{
int num1,num2;
printf(“Enter the value”);
scanf(“%d%d”,&num1,&num2);
printf(“the values are %d and %d”,num1,num2);
return 0;
}
8