# Noob question

• 05-01-2005
EvilHunter
Noob question
I know this is a very simple problem but I cant figure it out. I have been doing the tutorials and trying to learn but I got stuck on the IF... I know, kind of sad.
This is my code:

Code:

```#include <iostream> using namespace std; int main() {   int age;   cout<<"How old are you? ";   cin>> age;   cin.ignore();   if ( age < 50 ) {       cout<<"You are under 50! I know, I'm amazing!\n";       }   else if ( age == 14 || 15) {       cout<<"Blah/n";       }    else if ( age == 100 ) {       cout<<"You're older than my grandmother!\n";       }   else {     cout<<"You're really old\n";     }   cin.get(); }```
Everything works except if age equals 15 or 14. If age equals 15 or 14 it still executes if ( age < 50 ) {....
Can you tell me whats wrong. Please.

-Thx
• 05-01-2005
Glirk Dient
When you are entering 14 or 15 it is still less than 50 so it executes that.

Now find a way to fix that. =)
• 05-01-2005
sand_man
Code:

```else if ( age == 14 || 15) { //should be... else if ( age == 14 || age == 15) {```
A better way to write it.
Code:

```  if( age < 15 ) {       cout<<"Blah/n";   }   else if( age < 50 ) {     cout<<"You are under 50! I know, I'm amazing!\n";   }    else if ( age == 100 ) {     cout<<"You're older than my grandmother!\n";   }   else {     cout<<"You're really old\n";   }```
• 05-01-2005
EvilHunter
Quote:

Originally Posted by sand_man
Code:

```else if ( age == 14 || 15) { //should be... else if ( age == 14 || age == 15) {```
A better way to write it.
Code:

```  if( age < 15 ) {       cout<<"Blah/n";   }```

Thank you for the help. That worked. But for what I was doing < 15 was to broad of a range. :D
• 05-01-2005
elnerdo
To fix that, put your else-ifs in numerical order..

(This is pseudocode cause im too lazy to type it in real code)