Formatted Input. scan function in C
Formatted Input: Formatted input refers to an input data that has been arranged in a
particular format.
scanf(): Scanf() function can be
used input the data into the memory from
the standard input device. This function
can be used to enter any combination of numerical Values, single characters and
strings. The function returns number of
data items.
Syntax:-
scanf (“conversion strings”, &arg1,&arg2,--------&arg-n);
Where conversion
string reefers to a string containing certain required formatting
information and arg1, arg2----arg-n
are arguments that represent the individual input data items.
Example:
Where %s , %d, %f, %c with % are conversion
characters. The conversion characters
indicate the type of the to corresponding data. Commonly used conversion
characters for data input.
int a; float b; char n,sn[20];
scanf(“%d”,&a);
scanf(“%f”,&b;
scanf(“%c”,&n);
scanf(“%s”,sn);
scanf(“%d%f%c%s”,&a,&b,&n,sn);
No comments:
Post a Comment