In this example, you’ll learn to print the number entered by a user using C++ cout statement.
Here in the below program, we’ll Print Number on the output console.
Program to Print Number Entered by User
#include <iostream> using namespace std; int main() { int number; cout << "Enter an integer: "; cin >> number; cout << "You entered " << number; return 0; }
Output
Enter an integer: 23 You entered 23
This program asks the user to enter a number.
When the user enters an integer, it is stored in variable number using cin
.
Then it is displayed on the screen using cout
.
Related Programs
- C++ “Hello, World!” Program
- C++ Program to Add Two Numbers
- C++ Program to Find Quotient and Remainder
- C++ Program to Find Size of int, float, double and char in Your System
- C++ Program to Swap Two Numbers
- C++ Program to Find ASCII Value of a Character
- C++ Program to Multiply two Numbers
Ask your questions and clarify your/others doubts on Addition of Two Numbers by commenting. Documentation.
Please write to us at [email protected] to report any issue with the above content or for feedback.