0

I'm having problem compiling it!

#include <iostream> using namespace std; int main() { int age=20; if (age >15){ cout <<"adult"; } } else { cout<<"teenager"; } else { if (age>0){ cout <<"something is wrong "; } } return 0; } // can't figure out my error please help

7th Jan 2017, 7:02 AM
neil
neil - avatar
10 Antworten
+ 6
#include <iostream> using namespace std; int main() { int age=20; if (age >15) { cout <<"adult"; } else { if (age<0) cout <<"something is wrong "; else cout<<"teenager"; } return 0; }
7th Jan 2017, 7:09 AM
Megatron
Megatron - avatar
+ 3
bro check how you have used these { } you already closed the int main () block after completing the if block !!! #SiD
7th Jan 2017, 7:24 AM
Siddharth Naithani
Siddharth Naithani - avatar
+ 2
#include <iostream> using namespace std; int main() { int age=20 if (age >15) cout <<"adult"; else if (age < 15) cout<<"teenager"; else cout <<"something is wrong "; return 0; }
7th Jan 2017, 7:10 AM
Yugen Chokshi
Yugen Chokshi - avatar
+ 2
bro just shift the else of teenager and shift it after the ending if the code gonna work
7th Jan 2017, 7:47 AM
navdeep dhakar
navdeep dhakar - avatar
+ 2
just shift else after if of ending
7th Jan 2017, 7:49 AM
navdeep dhakar
navdeep dhakar - avatar
+ 1
Your code is wrong!
7th Jan 2017, 7:06 AM
Yugen Chokshi
Yugen Chokshi - avatar
+ 1
thanks every one for help :) @yugenchkkshi @navdeepdhakar @siddharthnaithani @Megatron
7th Jan 2017, 12:00 PM
neil
neil - avatar
+ 1
#include <iostream> using namespace std; int main() { int age=20; cin>>age; if (age >15) { cout <<"adult\n"; } if(age<15) { cout<<"teenager"; } return 0; }
14th Feb 2017, 1:56 PM
subyyal
subyyal - avatar
0
@yugenchokshi even ur code is wrong kid it's not compiling !
7th Jan 2017, 12:05 PM
neil
neil - avatar
0
try eliminating the first declaration of age=20. only declare int age; it will work
10th Jun 2017, 2:35 PM
navdeep dhakar
navdeep dhakar - avatar