Non desired output

Hi, im new to c++ and this website. Ive done some reasearch on this problem and i cant figure it out. I'm trying to use if and else statements correctly. Heres the code.

#include <iostream>

using namespace std;
int main()

{
int Ia;
cout << "How old are you?" << endl;
cin >> Ia;
if (Ia >= 35)
{ cout << "Your getting old!" << endl;
}
else (Ia <= 35);
{
cout << "Still a youngin!" << endl;
}
system ("pause");
return 0;
}

the output I get is
Your getting old!
Still a youngin!

I want it to only do one or the other depending on if the user inputs a value higher or lower than 35.
Your code formatted and in code tags:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

using namespace std;
int main() {
    int Ia; 
    cout << "How old are you?" << endl;
    cin >> Ia;
    if (Ia >= 35) {
        cout << "Your getting old!" << endl;
    } else
        (Ia <= 35);
    {
        cout << "Still a youngin!" << endl;
    }
    system ("pause");
    return 0;
}


As you can see now, you made some mistakes at the else statement:
You tried to write a condition to the else, which you can't do. Instead, an else if can have a condition. You made another mistake in the mistake (by putting a semicolon after (Ia <= 35) ), that is why it compiled. Try rewriting your code, if you still have troubles come back, and post your new code (next time in [code][/code] tags).
Thank you so much, completely fixed the problem!
Topic archived. No new replies allowed.