what is wrong with this nasted if else statement code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is wrong with this nasted if else statement code

#include <iostream> using namespace std; int main() { int age; cin>> age; if(age>0); { if(age<=10); { cout<<"child"; } else; { if(age<=50); { if(age<=18); { cout<<"teenager"; } else; { cout<<"adult"; } } else; { cout<<"You are too old for this job"; } } } else; {cout<<"please enter valid number";} }

22nd Oct 2018, 10:09 AM
Shubham Maurya
Shubham Maurya - avatar
5 Answers
+ 2
Ok are displaiyng the brackets of if - else wrong. And if - else statments can't have ; for working. I played with your code. Check here: https://code.sololearn.com/cQxfzhMRdoxS
22nd Oct 2018, 10:27 AM
Anya
Anya - avatar
+ 2
All the ; after the ifs and the elses are wrong. For example: if(age >0); Should be if(age>0)
22nd Oct 2018, 10:21 AM
fra
fra - avatar
+ 1
thanks i was messing up with curly brackets and thief is semicolon 🤔
22nd Oct 2018, 2:30 PM
Shubham Maurya
Shubham Maurya - avatar
0
wrong if (age>0) solution is ex.if (age>70)
26th Oct 2018, 6:37 PM
Awesome gameplays
Awesome gameplays - avatar
0
no, i solved it . U can check here https://code.sololearn.com/cX1Emi4228a5/?ref=app
28th Oct 2018, 12:14 PM
Shubham Maurya
Shubham Maurya - avatar