Read User Input Using cin in C++
On this page (6sections)
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
Related Pages
Learn the concept first, then study the code:
- C++ Programs — Browse all C++ Programs.
- C++ Programming Structure — Tutorial — structure of a C++ program and Hello World.
- Hello World C++ Example Program — More in c basic example programs.
- Simple Addition ( Add Two Integers ) Example Program — More in c basic example programs.