scanf( ) function in 'C'
A) Formatted Input and Output ( )
1) scanf( ):- This is used in ‘C’ programming to supply the data in a fixed formatted. Hence it is the formatted input function in ‘C’. The format should be specified by the user.
The Syntax is:-
scanf(“control string”, arg1, arg2, arg3, …………., argn);
The control string gives the required formatting information. It must begin with the symbol % followed by a conversion character and a number specifying the width these number is optional.
Conversion Character
Meaning
d
the data item an integer value
f
the data item is a floating value
c
the data item is a Single Character
s
the data item is a string
The argument represent individual data item. If the argument contains variables name having integer or float value or a single character constant then such argument must begin with symbol & (ampersand).
If the argument contains a string constant then & (ampersand) is not required.
1) scanf( ):- This is used in ‘C’ programming to supply the data in a fixed formatted. Hence it is the formatted input function in ‘C’. The format should be specified by the user.
The Syntax is:-
scanf(“control string”, arg1, arg2, arg3, …………., argn);
The control string gives the required formatting information. It must begin with the symbol % followed by a conversion character and a number specifying the width these number is optional.
Conversion Character
Meaning
d
the data item an integer value
f
the data item is a floating value
c
the data item is a Single Character
s
the data item is a string
The argument represent individual data item. If the argument contains variables name having integer or float value or a single character constant then such argument must begin with symbol & (ampersand).
If the argument contains a string constant then & (ampersand) is not required.
0 comments:
Post a Comment