Input Statement (cin)
In C++ cin is known as an input statement.
It is used to input data into the program.
The general form of the cin is as follow:
cin is a predefined object defined in istream.h file which represents the standard input stream in C++ which is keyboard.
>> is known as extraction or get from operator. Because it gets the value from the keyboard and assign it to the variable on it’s right.
Variable_Name is the name of the variable to which you want to assign the entered value.
We can also cascade >> operator to enter multiple values using single cin statement.
Output Statement (cout)
In C++ cout is known as an output statement.
It is used to display the content of the variable or string on the output screen.
The general form of cout statement is follow:
cout << Variable_Name or “String”;
cout is a predefined object defined in ostream.h which represents the standard output stream in C++ which is monitor.
<< is an overloaded bitwise shift left operator. It is also known as insertion or put to operator. It inserts the contents of the variable on its right to the object on its left.
Variable_Name or “String” represents the value to be displayed on the screen.
cout << a;
cout << “Welcome To C++”;
We can also cascade << operator to display value of more then one variable using single cout statement.