Input and Output in C 65
Input and Output Functions
Formatted Functions
Input Output
scanf () p rin tf ()
Unformatted Functions
Input
getchO
getcheO
getchar ()
gets()
Outpur
putchO
putchar ()
put()
Table 4.1 Formatted and unformatted functions
4.2 FORMATTED FUNCTIONS
a The prin tf () statem ent The p r in t f () function prints all types of data values to the console. It
requires conversion symbol and variable names to print the data. The conversion symbol and variable
names should be same in number. The example of p r in t f () statement is given below.
in t x*2;
flo a t y *2.2 ;
char z e 'C ';
p r in tf ("%d %f % c",x ,y ,z ) ;
}
OUTPUT:
2 2.2000 C
In the above program %d corresponds to ' x ' variable, %f t o y and %c to ' zThe conversion
symbol given by the user helps to p rin t£ () to identify the data type of the given variable. In case, if
mismatch occurs the value of the variable is converted according to the conversion symbol given.
Example
# Include <stdlo.h>
xnain()
in t y -65;
c lr s c r ( ) ;
printf(“%c %d",y,y );
return 0;
I
OUTPUT:
A 6 5
Example
mainO
{
{
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.33.235