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 >> 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 ;
Algorithm to print number entered by user
- Declare variable
- Take a user input using cin statement
- Print number using cout statement
C++ Program to Print Number Entered by User
using namespace std;
cout << "Enter number : ";
cin >> number;
cout << "You entered number : " << number;
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