Formatted input:
When the input data is arranged in a specific format, it is called formatted input. scanf function is used for this purpose in C.
General syntax:
scanf(“control string”, arg1, arg2..);
Control string here refers to the format of the input data. It includes the conversion character %, a data type character and an optional number that specifies the field width. It also may contain new line character or tab. arg1, arg2 refers to the address of memory locations where the data should be stored.
Example:
scanf(“%d”,&num1);
Eg:
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf("Enter a number");
scanf("%d",&i);
printf("Entered number is: %d",i);
getch();
}