0

cin >> question

Hey there. How do I create a question/command that asks the user for input, e.g. “Type in number”. It should be very simple but I just started with the tutorials...

12th May 2020, 4:16 PM
The_Fox
The_Fox - avatar
3 RĂ©ponses
+ 2
cout<<"Type in number";
12th May 2020, 4:26 PM
Abhay
Abhay - avatar
0
Thank you. I did basically that ( cout << “Type in a, b, or c> “; see below) but the text was printed to the screen after I was informed to type in something. Maybe it‘s because I‘m working with my iPad... I will try some other things maybe ;)
13th May 2020, 4:29 AM
The_Fox
The_Fox - avatar
0
int main() { cout << "Why are you learning? Type in 1, 2 or 3: " << endl; string a = "I am learning C++"; string b = "Because it is fun"; string c = "Well, ... I don't know"; int number = 0; cin >> number; switch (number) { case 1: cout << a; break; case 2: cout << b; break; case 3: cout << c; break; default: cout << "Wrong input"; } }
13th May 2020, 4:30 AM
The_Fox
The_Fox - avatar