In this tutorial you will learn about the C++ Program to Print Number Entered by User and its application with practical example.
C++ Program to Print Number Entered by User
In this tutorial, we will learn to create a C++ program that will Print Number Entered by Users in C++ programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C++ programming topics:
- Operators in C++ Programming.
- Basic Input and Output function in C++ Programming.
- Basic C++ Programming.
Print Number Entered by Users
The printing of numbers from the user at a console is very essential. Number if can’t be printed on the screen then the user can never get the output for the calculation. That’s why number printing is important.
Algorithm to print the number entered by users in the output:-
1 2 3 4 5 6 7 |
1. Declaring the variables for the program. 2. Taking the input from the user in number format. 3. Printing the data taken in input from the user in number format. 4. End program. |
Program to Print Number Entered by Users
In this program, we will take input numbers from the user and then we will print the number on the console with the help of a short c++ program.
With the help of this program, we can take input and Print Number Entered by Users.
Program to Print Number Entered by Users:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/* C++ Program to Print number Entered by User */ #include<iostream> using namespace std; int main() { /* variable definition and initialization for the program */ //no will store the number value for the program int no; // take input from end-user cout << "Enter an Integer: "; cin >> no; /* Printing the output for the number defined in to a variable in the program with out taking input from the user */ cout << "Entered Integer is: " << no << endl; return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- no = it will hold the input number value from the user.
Taking Input from the user.
Printing the data in the output in the number format.