Input-Output Operator in C++

iostream File

  • We have used the following #include directive in the program  #include <iostream>
  • This directive causes the preprocessor to add the contents of the iostream file to the program.
  • It contains declarations for the identifier cin , cout and the operator >> , <<
  • The header file iostream should be included at the beginning of all programs that use input/output statements.

In C++ Input-Extraction Operator >> take value from keyboard and Output-Insertion Operator << put (display) value on screen

Input (Extraction ) Operator >> in C++

cin » variable-1 >> variable-2>> variable-n;

in C++ Output Operator also known as Extraction operator

  • The program to wait for the user to type in a number. The number keyed in is placed in the variable-1 to n.
  • The identifier cin (pronounced ‘C in’) is a predefined object in C++ that corresponds to the standard input stream. Here, this stream represents the keyboard.
  • The operator » is known as extraction or get from It extracts <or takes) the value from the keyboard and assigns it to the variable on its right .

    Input-Extraction operator >>
    Extraction Operator also Input Operator in C++

Output (Insertion ) Operator << in C++

cout <<“C++ is better than C”;

in C++ Output Operator also known as Insertion operator

  • The statement causes the string in quotation marks to be displayed on the screen.
  • This statement introduces two new C++ features, cout and «.
  • The identifier cout is a predefined object that represents the standard output stream in C++. Here, the standard output stream represents the screen.
  • It is also possible to redirect the output to other output devices.
  • The operator « is called the insertion or put to
  • It inserts (or sends) the contents of the variable on its right to the object on screen


Insertion Output Operator >> in C++
Insertion Output Operator >> in C++


Enter two Values



SUM              =  21

AVERAGE    =  10.50

(Visited 61 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

Reload Image