This program declares a variable number
of type int
to hold the number entered by the user. It then uses the cout
object to print a prompt asking the user to enter a number, and the cin
object to read the number from the standard input stream. Finally, it uses cout
again to print the number entered by the user.
I hope this helps! Let me know if you have any questions.
Code listed below:
#include <iostream>
int main()
{
int number; // Declare a variable to hold the number
std::cout << "Enter a number: "; // Prompt the user to enter a number
std::cin >> number; // Read the number from the standard input stream
std::cout << "You entered: " << number << std::endl; // Print the number
return 0;
}
Leave a Reply