In this tutorial, we will learn how to write a simple C++ program that will print a number entered by the user.
First, we will declare a variable to hold the user input. We can use the “int” data type to store integer values.
int number;Next, we will prompt the user to enter a number. We can use the “cout” statement to display a message to the user.
cout << "Enter a number: ";Then, we will use the “cin” statement to get input from the user and store it in the “number” variable.
cin >> number;Finally, we will use the “cout” statement to display the number entered by the user.
cout << "The number you entered is: " << number << endl;Here is the complete program:
#include <iostream>
using namespace std;
int main()
{
int number;
cout << "Enter a number: ";
cin >> number;
cout << "The number you entered is: " << number << endl;
return 0;
}
This program will ask the user to enter a number, store the input in the “number” variable, and then display the number entered by the user.
In conclusion, this is a simple C++ program that can be used to get user input and display the output.
It is a basic program that can be used as a starting point for more complex programs that involve user input.




