INPUT/OUTPUT
STATEMENTS
In C Language input and output function
are available as C compiler function or C
library provided with each C compiler
implementation. These all functions are
collectively known as Standard I/O
Library function. Here I/O stands for Input
and Output used for different inputting
and outputting statements.
Input Output Statements
 Input and Output statement are used to read
and write the data in C programming. These
are embedded in stdio.h (standard
Input/Output header file).
 There are mainly two of Input/Output functions
are used for this purpose. These are
discussed as:
a) Formatted I/O Functions
b) Unformatted I/O Functions
Formatted I/O Functions
 Formatted I/O functions which refers to an Input or
Ouput data that has been arranged in a particular
format. There are mainly two formatted I/O
functions discussed as follows:
a) scanf()
b) printf()
scanf()
 The scanf() function is an input function. It used to read the mixed
type of data from keyboard. You can read integer, float and
character data by using its control codes or format codes. The
general syntax is as:
scanf(“specifiers”, &variables);
printf()
 This ia an output function. It is used to
display a text message and to display the
mixed type (int, float, char) of data on screen.
The general syntax is as:
printf(“Your message”);
Escape Sequence
 When you’re programming in the C language,
sometimes you need to refer to a key press
that doesn’t result in a specific character.
Other times, you need to refer to a specific
character literally that normally has a different
meaning in C. In either case, you need an
escape sequence. The following table lists the
escape sequences you need to program in the
C language.
Unformatted I/O functions
 There are mainly six unformatted I/O
functions discussed as follows:
a) getchar()
b) putchar()
c) gets()
d) puts()
e) getch()
f) getche()
getchar()
 This function is an Input function. It is used for reading
a single character from the keyboard.
 The general syntax is as:
 v = getchar();
where v is the variable of character type. For example:

putchar()
 This function is an output function. It is used
to display a single character on the screen.
The general syntax is as:
 putchar(v);
gets()
 This function is an input function. It is used
to read a string from the keyboard. The
general syntax is as:
 char n[20];
gets(n);
puts()
 This is an output function. It is used to
display a string inputted by gets() function.
The general syntax is as:
puts("text line");
getch()
 This is also an input function. This is used to
read a single character from the keyboard like
getchar() function. The general syntax is as:
v = getch();
getche()
 All are same as getch() function except it is
an echoed function. It means when you type
the character data from the keyboard it will
visible on the screen. The general syntax is as:
 v = getche();

Lesson 7 io statements

  • 1.
    INPUT/OUTPUT STATEMENTS In C Languageinput and output function are available as C compiler function or C library provided with each C compiler implementation. These all functions are collectively known as Standard I/O Library function. Here I/O stands for Input and Output used for different inputting and outputting statements.
  • 2.
    Input Output Statements Input and Output statement are used to read and write the data in C programming. These are embedded in stdio.h (standard Input/Output header file).  There are mainly two of Input/Output functions are used for this purpose. These are discussed as: a) Formatted I/O Functions b) Unformatted I/O Functions
  • 3.
    Formatted I/O Functions Formatted I/O functions which refers to an Input or Ouput data that has been arranged in a particular format. There are mainly two formatted I/O functions discussed as follows: a) scanf() b) printf()
  • 4.
    scanf()  The scanf()function is an input function. It used to read the mixed type of data from keyboard. You can read integer, float and character data by using its control codes or format codes. The general syntax is as: scanf(“specifiers”, &variables);
  • 5.
    printf()  This iaan output function. It is used to display a text message and to display the mixed type (int, float, char) of data on screen. The general syntax is as: printf(“Your message”);
  • 6.
    Escape Sequence  Whenyou’re programming in the C language, sometimes you need to refer to a key press that doesn’t result in a specific character. Other times, you need to refer to a specific character literally that normally has a different meaning in C. In either case, you need an escape sequence. The following table lists the escape sequences you need to program in the C language.
  • 8.
    Unformatted I/O functions There are mainly six unformatted I/O functions discussed as follows: a) getchar() b) putchar() c) gets() d) puts() e) getch() f) getche()
  • 9.
    getchar()  This functionis an Input function. It is used for reading a single character from the keyboard.  The general syntax is as:  v = getchar(); where v is the variable of character type. For example: 
  • 10.
    putchar()  This functionis an output function. It is used to display a single character on the screen. The general syntax is as:  putchar(v);
  • 11.
    gets()  This functionis an input function. It is used to read a string from the keyboard. The general syntax is as:  char n[20]; gets(n);
  • 12.
    puts()  This isan output function. It is used to display a string inputted by gets() function. The general syntax is as: puts("text line");
  • 13.
    getch()  This isalso an input function. This is used to read a single character from the keyboard like getchar() function. The general syntax is as: v = getch();
  • 14.
    getche()  All aresame as getch() function except it is an echoed function. It means when you type the character data from the keyboard it will visible on the screen. The general syntax is as:  v = getche();