Write a C++ program to print the number entered by a user using C++ cout statement.
C++ Code:
1 2 3 4 5 6 7 8 9 10 11 12 | #include <iostream> using namespace std; int main() { int number; cout << "Enter an integer: "; cin >> number; cout << "You entered " << number; return 0; } |
Output:
This program asks user to enter a number.
When user enters an integer, it is stored in variable number using cin
.
Then it is displayed in the screen using cout
.