To take input from the user via console, we use the cin statement.
cin is a predefined variable that reads data from the keyboard with the extraction operator (>>).
Example1:
int x;
cin >> x; // Get user input from the keyboard
cout << x;
Input: 5
Output: 5
Example2:
string x;
cin >> x; // Get user input from the keyboard
Input1: “Hello”
Output1: “Hello”