Friday, December 11, 2009

3.4 WRITING OUTPUT DATA - THE printf FUNCTION

Output data can be written from the computer onto a standard output device using the library function printf.It is similar to the input function scanf,except that its purpose is to display data rather than to enter it into the computer.

In general terms, the printf function is written as

printf(control string,arg1,arg2,arg3,.....,argn)

where control string refers to a string containing certain required formatting information,and arg1,arg2,arg3,....,argn are arguments that represent the the individual output data items.

Here is a simple program that makes use of the printf function



#include

main() /*print several floating point numbers*/
{

float i=2.0,j=3.0;
printf("%f %f",i,j);

}

The output of the program will be as follows:

2.000000 3.000000

No comments:

Post a Comment