Input / Output Statements

Input / Output Statements

  • Every computer program require input and output function to enter and display the output.
  • The users have to enter the data that will be stored in the memory of computer, process the data and finally display the result .
  • #include<stdio.h>  header file is used for the input / output function.

Input/ output instruction:  This type of instruction are used to perform the function of supplying the input data to program and obtaining the output results from it.

Standard input/output functions.  

scanf() function :  The scanf() function is used to accept input data from the standard device i.e.  keyboard in a fixed format.

Syntax:  scanf(“format string”,arguments);

Format string contains the format specifiers which begin with character ‘%’ and another character according to data type.

Format specifier Input types Data type
%d or %i






Short signed integer

Short unsigned integer

Long signed integer

Long unsigned integer

Unsigned hexadecimal integer

Unsigned octal integer



Single precision float

Double precision float



Signed character

Unsigned character

%s string string



printf() function

This function is used to output data from the computer on to  standard output device in a fixed format.


Printf(“format string”,argument);

Demonstration for input / output function

void main()
int a ;
printf(“enter any number :”);
printf(“enterd number is = %d”,a);

Flow of program :
Enter any number : 5
Entered number is = 5