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
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;
}
+ 3
bro check how you have used these { } 
you already closed the int main () block after completing the if block !!!
#SiD
+ 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;
}
+ 2
bro just shift the else of teenager and shift it after the ending if the code gonna work
+ 2
just shift else after if of ending 
+ 1
Your code is wrong! 
+ 1
thanks every one for help :) @yugenchkkshi @navdeepdhakar @siddharthnaithani @Megatron
+ 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;
 
}
0
@yugenchokshi even ur code is wrong kid it's not compiling ! 
0
try eliminating the first declaration of age=20. only declare int age; it will work



