Input and output statements
Output Operator:
The syntax of cout statement
cout<<”Welcome to C++ language \n”; //one form of cout statement
The string between quotes to be displayed on the screen. The “cout” is a predefined object that represents the standard output stream (screen in this case) in C++.The operator ‘<<’ is called the insertion or put to the operator. It inserts (or sends) the contents of the variable on its right to the object on its left. This corresponds to the familiar printf() operation in C’.

The object ‘cout’ has a simple interface. If the string represents a string variable, then the following statement will display its contents.
cout<<variable_name; //another form of cout statement
This statement prints the value of that particular variable_name on the output screen.
Input Operator:
The syntax of cin statement:
cin>>variable_name; // cin reads the value from keyboard
cin is an input statement and causes the program to wait for the user to type in a number. This number keyed in is placed in the particular variable_name. The identifier ‘cin’ is also a predefined object in C++ that corresponds to the standard input stream (keyboard in this case).
The operator ‘>>’ is known as extraction or get from the operator. It extracts (or takes) the value from the keyboard and assigns it to the variable on its right. This corresponds to the familiar scanf() operation in C’.
Cascading of input/output operators:
In the statement
cout<<”Another form of cout statement is:“<<variable_name<<”\n”;
We used the insertion operator ‘<<’ repeatedly for printing the result. First, we send the string “Another form of cout statement is: “to cout and then send the value of ‘variable_name’. Finally, it sends the new line character so that the next output will be in the new line. The multiple uses of ‘<<’ in one statement are called cascading.
Similar to ‘<<” the extraction operator (‘>>”) can also cascade.
cin>>variable_name1>>variable_name2;
Values are assigned from left to right, in other words, in an entry 10 20, 10 will be assigned to variable_name1 and 20 will be assigned to variable_name2.
Note: cin can only read a single word and so we cannot use names with blank spaces.
Example Program:
Program to input the integer, float, char, and string using cin statement and display using cout statement.
#include<iostream>
#include<conio.h>
using namespace std;
int main( )
{
int i;
float f;
char ch;
char name[50];
cout<<"Enter the integer, float and character values:";
cin>>i>>f>>ch; //reading the values from keyboard
cout<<"Enter the string:";
cin>>name;
cout<<"The values are:\n";
cout<<" i = "<<i<<" f = "<<f<<" ch = "<<ch; //displaying the values on output screen
cout<<"\n name = "<<name;
return 0; // return zero statement
}
Output: