Input and output operators in C++ | Insertion operator in C++ | Extraction operator in C++
These operators are used to perform input and output operations in a C++ program.
There are two types of Input and output operators in C++
1. Insertion Operator in C++ (<<)
Insertion operator in C++ also known as output operator can be used with cout statement to show output on the screen.
Example:
cout<<”hi”;
Above statement shows message hi on the screen.
2. Extraction Operator(>>)
Extraction operator in C++ also known as input operator can be used with cin statement to read value of some variable from keyboard.
Example:
int n; cin>>n;
Above example demonstrates how to read value of variable n from keyboard.
//Program to demonstrate the use of Input and Output operators.
#include<iostream>
using namespace std;
int main()
{
int n;
cout<<”\nEnter an integer value=”;
cin>>n;
cout<<”\nValue=”<<n;
return 0;
}
Output:
Enter value of num=10 a=10![]()

