C++ Program To Print Number Entered By User - Programiz
Maybe your like
Become a certified C++ programmer.
ENROLLPopular Tutorials
C++ if...else Statement C++ for Loop Arrays in C++ Strings in C++ C++ Class & Objects Start Learning C++Popular Examples
Create a simple calculator Check prime number Print the Fibonacci sequence Check if a number is palindrome or not Program to multiply matrix Explore C++ ExamplesReference Materials
iostream cmath cstring ctime View allCreated with over a decade of experience.
- Learn
- Practice
- Compete
Certification Courses
Created with over a decade of experience and thousands of feedback.
Learn Python Learn HTML Learn JavaScript Learn SQL Learn DSA View all Courses onBecome a certified C++ programmer.
Try Programiz PRO!Popular Tutorials
C++ if...else Statement C++ for Loop Arrays in C++ Strings in C++ C++ Class & Objects Start Learning C++ All C++ TutorialsReference Materials
iostream cmath cstring ctime View all Python JavaScript C C++ Java R KotlinBecome a certified C++ programmer.
Try Programiz PRO!Popular Examples
Create a simple calculator Check prime number Print the Fibonacci sequence Check if a number is palindrome or not Program to multiply matrix All C++ ExamplesC++ Examples
- C++ "Hello, World!" Program
- Print Number Entered by User
- Add Two Numbers
- Find Quotient and Remainder
- Find Size of int, float, double and char in Your System
- Swap Two Numbers
- Find ASCII Value of a Character
- Multiply two Numbers
C++ Tutorials
- Calculate Average of Numbers Using Arrays
- Display Factors of a Number
- Add Two Matrix Using Multi-dimensional Arrays
- Find Transpose of a Matrix
- Access Elements of an Array Using Pointer
- Calculate Sum of Natural Numbers
Example: 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 23This program asks the user to enter a number.
When the user enters an integer, it is stored in variable number using comment.
Then it is displayed on the screen using cout.
Starting from this example, we will be using the std namespace using the code:
using namespace std;This will allow us to write cout, cin, endl, etc. instead of std::cout, std::cin, std::endl respectively.
This is simply to make our code cleaner and more readable.
However, using the std namespace is considered a bad practice and we highly recommend you drop this practice once you've mastered the basics of C++.
Share on: Did you find this article helpful?Sorry about that.
How can we improve it? Feedback * Leave this field blankYour builder path starts here. Builders don't just know how to code, they create solutions that matter.
Escape tutorial hell and ship real projects.
Try Programiz PRO- Real-World Projects
- On-Demand Learning
- AI Mentor
- Builder Community
Related Examples
C++ Example
Display Factors of a Number
C++ Example
Calculate Average of Numbers Using Arrays
C++ Example
Add Two Matrix Using Multi-dimensional Arrays
C++ Example
Check Whether a Number is Palindrome or Not
Tag » How To Print In C++
-
C++ Output (Print Text) - W3Schools
-
How To Print In C++ | Udacity
-
C++ "Hello, World!" Program - Programiz
-
Basic Input/Output - C++
-
How To Print \" In C++ - Stack Overflow
-
Printing Output In Multiple Lines In C++ - GeeksforGeeks
-
How To Read And Print An Integer Value In C++ - GeeksforGeeks
-
C++ Tutorial: Simple Input And Output - CUED
-
C++ Tutorial For Beginners 3 - C++ Output (Print Text) - YouTube
-
Windows With C++ - Using Printf With Modern C++ | Microsoft Learn
-
How Do I Print 5.00 In Place Of 5 In A C++ Code? - Quora
-
How To Print \n In C Or C++ Programming - Quora
-
C++ Exercises: Print The Result Of The Specified Operations - W3resource
-
An Introduction To C++ Programming For First-time Programmers