Print number entered by user is a basic and simple program in cpp programming.
In this tutorial we are going to one simple and easy program in cpp programming.
We print the number entered by user using cout statement in c++.
How to print number entered by user
For this first we need to take a input from user. For this we use cin statement in c++.
Cin in cpp : For taking the input from the user in program the cin is used .
Lets see syntax to take input
cin syntax
cin >> variable_name;
After taking input we print number using cout statement in c++.
Output stream : Cout is a Output stream in cpp programming.
For printing the statement to the screen the cout output stream is used.
cout syntax :
cout<< statement ;
Example
int a;
cin>>a;
cout<<”a=”<<a;
Algorithm to print number entered by user
- Start
- Declare variable
- Take a user input using cin statement
- Print number using cout statement
- End
C++ Program to Print Number Entered by User
12345678910111213141516171819 | #include <iostream>using namespace std;int main(){ int number; cout << “Enter number : “; cin >> number;cout << “You entered number : ” << number; return 0;} |
Output :

Explanation:
1. Execution starts with the main function.
2. Declare the variables
number => to take input from user
3. Next take a user input a number using cin statement
cin >> number; => number=10
4. Now print the number user entered using cout statement
cout << “You entered number : ” << number;
=>You entered number : 10