Skip to main content

Read User Input Using cin in C++

1 min read Updated June 30, 2026
Share:
On this page (7sections)

About this program

This is an example program in c basic example programs. Read the concept first: C++ Programming Structure, then study the code and output below.

Definition of Cin

The cin read input from the keyboard. The cin is the stream extraction operator (>>), which is mainly used for reading the input from the console.

Unlike C, cin reads all data types without any notation.

Syntax

cin >> varable_name;

Simple Program for read user Input (Integer) Using cin

/* Simple Program for Read user Input Using cin In C++ */
/* Add Two Integers Programs, Addition Programs,C++ Examples */

// Header Files
#include<iostream>
#include<conio.h>

//Main Function

using namespace std;

int main() {
   // Local Variable 'a' Declaration
   int a;

   cout << "Simple Program for Read user Input (Integer) Using cin \n";

   cout << "Enter Number : ";
   cin >> a;

   cout << "Entered Input Is = " << a;

   // Wait For Output Screen
   getch();

   //Main Function return Statement
   return 0;
}

Sample Output

Simple Program for Read user Input (Integer) Using cin
Enter Number : 100
Entered Input Is = 100

Learn the concept first, then study the code:

Frequently Asked Questions

What does this C++ program do?
It is a C++ example program that demonstrates Read User Input Using cin, including the complete source code and the expected sample output.
How do I compile and run this C++ program?
Save the code in a `.cpp` file, compile it with `g++ filename.cpp -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses reading user input, illustrating a common pattern in C++ programming.

Related Tutorials

Search tutorials