+ 2
Why wont my code work
#include <iostream> using namespace std; int main(){ int age; cout << "Please enter age. \n"; cin >> age >> endl; if (age <= 17){ cout << "sorry you must me 18+ \n"; } if (age >= 18){ cout << "welcome"; } return 0; }
7 Réponses
+ 9
Try deleting the endl in cin. I think that's the error
+ 7
Yeah, the endl is the problem, you can't end the line when you are inputing stuff, does that make sense to you?
+ 6
@HunterDavis No problem man :)
+ 3
@fillip removing endl after cin fixed it thanks!
+ 1
u can use switch case to solve this problem and it is in switch.
and by the way you're program is right and it won't work in phones and phone is not capable to run the output
0
are you correctly indenting the ifs?
0
i think so