# Really newbie question about if

• 09-03-2002
SumeragiSubaru
Really newbie question about if
can you have more than 1 if else statement in an if statement
ie.

if(x>=64)
{
cout << "you are dead.";

else if(x<=11)
cout << "you are young.";

else if(x<19 && x>=12)
cout << "you are a teen.";

else if(x<=63 && x>=20)
cout << "you are an adult.";
}
• 09-03-2002
Prelude
>can you have more than 1 if else statement in an if statement
Yes.
Code:

```if(x>=64) { cout << "you are dead."; else if(x<=11) cout << "you are young."; else if(x<19 && x>=12) cout << "you are a teen."; else if(x<=63 && x>=20) cout << "you are an adult."; }```
No. This is an illegal construct because every else must have a matching if. Because you placed the else statements inside the first if, it will not work. This will though:
Code:

```if(x>=64)   cout << "you are dead."; else if(x<=11)   cout << "you are young."; else if(x<19 && x>=12)   cout << "you are a teen."; else if(x<=63 && x>=20)   cout << "you are an adult.";```
-Prelude
• 09-03-2002
SumeragiSubaru
thanks that really helped :cool: