## formated input and out put data

Formated input and out put

Formatted input means that data is arranged   in a particular   format and formatted out means that the out put is displayed in such a way that   they are in understandable and easy –to –use form .So we c an say that through format specification better presentation of result can be obtained .Formats for different specifiaction are as –

1.Format for integer
Input%wd

Where w is an integer number specifying   the width of input data. ‘d’ is the conversion specification character for integer   value.

Ex-
Scanf(“%2d %3d”, &a,&b);
Condition-
(i)When input data length is less than the given length ,Then   the given values are unaltered and stored and stored in given variables
Input:
26  39
Result:

26 is stored in a and 39 is stored in b

(ii) When input data length is equal   to the given length, then the given values are unaltered and
Stored in given variables.
Input:
26   394
Result:
26 is stored in a and 394 is stored in b
3) when input data length is more    than the given legth, then the given values are altered and stored   in the variable as –
Input :
269 3945
Result :
26 is stored in a and 9 is stored in b .
2.formated for integer out put.
%wd

Where   w is the integer number specifying the width of the output data

Ex-
Printf ( “a= 52d b= %3d”,a,b);
Condition –
(1)   Whene out put data is less than the gib=ven input data length input :
26 39
Result :
A=26 b= -39

Here the second data has one leading   blank (w-number of digits in b)

(ii) Whene out put   data lenghth is equal to the input d ata length   input:

26 394
Out put :
A=26 b= 394

(iii) when put put   data length is more than   the input data length

Input:
269 3945
Out put:
a=269 b= 3945

Print | posted on Wednesday, November 21, 2012 4:54 PM

## Feedback

No comments posted yet.

### Your comment:

Please add 2 and 1 and type the answer here: 