Tuesday 12 February 2013

Formatted Input and Output in C Programming Language


C provides standard functions, scanf() and printf(), for performing formatted input and output respectively. These functions accept, as parameters, a format specification string and a list of variables.

The format specification string is a character string which specifies the data type of each variable to be input or output and the size or width of the input or output.

Formatted Ouput

The function printf() is used for formatted output to standard output based on a format specification. The format specification string, along with the data to be output, are the parameters to the printf() function.

The syntax of the function printf() is:

printf(format, data1, data2, ...) ;

format is the format specification string. This string will contain, for each variable to be output, a specification beginning with the symbol % followed by a character called the conversion character.

Formatted Input

The function scanf() is used for formatted input from standard input and provides many of the conversion facilities of the function printf().

The syntax of the function scanf() is:

scanf (format, data1, data2, ...).

The function scanf() reads and converts characters from the standard input according to the format specification string and stores the input in memory locations represented by the other arguments.

0 comments:

Post a Comment

Powered by Blogger.