+ 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";} }
5 Antworten
+ 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
+ 2
All the ; after the ifs and the elses are wrong.
For example:
if(age >0);
Should be
if(age>0)
+ 1
thanks
i was messing up with curly brackets and thief is semicolon 🤔
0
wrong if (age>0) solution is ex.if (age>70)
0
no, i solved it . U can check here
https://code.sololearn.com/cX1Emi4228a5/?ref=app