Wednesday, November 21, 2012 #

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 

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

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

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.      
26   394
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.

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

 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 

269 3945
Out put:
a=269 b= 3945

posted @ Wednesday, November 21, 2012 4:54 PM | Feedback (0)

Copyright © Afsana Bano

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski