C++ keyboard input

To take keyboard input in C++, follow these steps:

  1. Include the necessary header file for input/output operations:
#include <iostream>
  1. Use the std namespace to avoid writing std:: before every input/output operation:
using namespace std;
  1. Declare variables to store the input:
int number;
string name;
  1. Use the cin object to receive input from the keyboard and store it in the variables:
cin >> number;
cin >> name;