Tuesday, December 8, 2020

Input & Output in C:

Format Specifiers: 


Reading Input Data: Input data can be entered into the memory from a standard input device (keyboard). C provides the scanf( ) library function for entering input data. This function can take all types of values (numeric, character, string) as input.

The scanf( ) function can be written as

scanf("control string" , address1, address2, ....);

This function should have at least two parameters. First parameter is a control string, which contains conversion specification characters. It should be within double quotes.

The address of a variable is found by preceding the variable name by an ampersand (&) sign. This sign is called the address operator and it gives the starting address of the variable name in memory

 Some examples of scanf( ) function are as-







Writing Output Data: Output data can be written from computer memory to the standard output device (monitor) usIng printf() library function. With this function all type of values (numeric, character or string) can be written as output.

The printf( ) function can be written as

printf("control string", variable 1, variable 2, );

In this function the control string contains conversion specification characters and text. It should be enclosed within'double quotes. The name of variables snould not be preceded by an ampersand(&) sign.

Some example of printf( ) function are as-











No comments:

Post a Comment