- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Environmental Science
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- articles and Answers
- Effective Resume Writing
- HR Interview articles
- Computer Glossary
- Who is Who
Write C++ Program to Print Number Entered by User
In this example, you'll learn to print the number entered by a user using C++ cout statement.
Program :
#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
Explanation :
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
.Advertisements
ads