> ## Content Index
> Fetch the complete content index at: https://developerinsider.co/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to take input by user in C++
- URL: https://developerinsider.co/how-to-get-input-by-user-in-cpp/
- Published: 2016-06-07T15:54:46.000Z
- Updated: 2018-03-29T17:01:15.000Z
- Author: Anit Kumar
- Tags: Primary, C++

**User input:** To enable the user to to input a value,use cin in combination with the extraction operator `(>>)`. The variable containing the extracted data follows the operator.  
The following example shows how to accept user input and store it in the `num` variables.  
**For example:**

```
int num;
cin>>num;

```

\*\*Note:-\*\*As with cout,extractions on cin can be chained to request more than one input in a statement:

```
int a,b;
cin>>a>>b;

```

**Accepting user input:** The following program prompts the user to input a number and stores it in the variable a:

**For example:**

```
#include<iostream>
using namespace std;
int main()
{
     int a;
     cout<<"Enter a number\n";
     cin>>a;
     return 0;
}

```

When the program runs, it displays the massage "Enter a number", and then wait for the user to enter the number and press `Enter`, or Return.  
The entered number is stored in the variable a.