How to Read and Print an Integer value in C++

Here we will see how to read integer from user and display in C++. To take input we will use the cin operator, and to display we will use cout operator. The syntax will be like −

Input −

int x;
cin >> x;

Output −

int x = 110;
cout << x;


 Live Demo

using namespace std;
int main(int argc, char const *argv[]) {
   int x;
   int y = 50;
   cout << "Enter some value: ";
   cin >> x;
   cout << "The given value is: " << x << endl;
   cout << "The value of y is: " << y;


Enter some value: 100
The given value is: 100
The value of y is: 50