+ 1

How to make a question in C++

Hey Everybody I have this code, using C++, where I collect the age of the person using "cin" and it's working perfectly, but is there a way to make a a question pop up asking "What's your age?" instead of the usual pop up text asking for input? Need the question to appear before the code asks for the input. Thanks for your help

22nd Jan 2017, 11:53 AM
Reenen
Reenen - avatar
6 odpowiedzi
+ 8
Reenen is probably asking about the Code Playground user input pop-up for C++. Unfortunately, the interface for C++ programs on SoloLearn (Code Playground) doesn't work like our desktop consoles. It has to take input prior to running the program. There is no way to change the text in the pop-up unless the devs upgrade C.Playground.
22nd Jan 2017, 12:17 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Thank you very much. Thank you both for your time. :)
22nd Jan 2017, 12:18 PM
Reenen
Reenen - avatar
+ 1
Will this make the question appear before asking for the input?
22nd Jan 2017, 11:57 AM
Reenen
Reenen - avatar
+ 1
#include <iostream> using namespace std; int main() { int age; cout<<"Your Age Category ="<<endl; cin>>age; //Enter one's age switch(age) { case 0 ... 1: cout<<"Infant"; break; case 2 ... 3: cout<<"Toddler"; break; case 4 ... 13: cout<<"Child"; break; case 14 ... 17: cout<<"Teenager"; break; case 18 ... 25: cout<<"Young Adult"; break; case 26 ... 65: cout<<"Adult"; break; case 66 ... 125: cout<<"Elderly"; break; } return 0; } This is the code. But adding the cout before the cin only makes text appear on output. I need it to appear and then afterwards it must ask for input. Sorry for the trouble.
22nd Jan 2017, 12:03 PM
Reenen
Reenen - avatar