User Inputs
- Generally ,Cout is used to output values.
- Here,cin to get user input.
- cin is a predefined variable that reads data from the keyboard with the extraction operator(>>).
Program:
#include <iostream>
int main() {
int user_input;
std::cout << "Enter a number: ";
std::cin >> user_input;
std::cout << "You entered: " << user_input << std::endl;
return 0;
}
Output:
Enter a number: [user enters a number, e.g. 42]
You entered: 42