#include <iostream>
int main() {
int num;
std::cout << "Enter a number: ";
std::cin >> num;
std::cout << "You entered: " << num;
return 0;
}
Enter a number: 5
You entered: 5
num
of type int
. The program then prompts the user to enter a number using the std::cout
and std::cin
objects from the iostream
library. >>
operator is used to input the user's number into the num
variable. Finally, the program uses std::cout
to output a message that displays the user's number to the console.