Expected primary-expression before '>' token.

I'm stuck and can't seem to solve this issue.
Here's the task that I need to do:
"Ask the user for two users' ages and indicate who is older, behave differently if both are over 100.
I get the error:
Expected primary-expression before '>' token. (Line 19)


This is my 4th day learning C++, so any advice is greatly appreciated.
Am I on the right track with the code below?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int age_1;
    int age_2;
         
    cout << "Please enter the age of user one: " << "\n";
    cin >> age_1;
    cout << "Please enter the age of user two: " << "\n";
    cin >> age_2;
    
    if (age_1 > age_2)
     
     cout << "User 1 is older then User two!" << "\n";
               
               
    else if (age_1 && age_2 == >100)
    { cout << "You guys are old!" << "\n";
    }
    else (age_1 < age_2);
 {
         cout << "User 1 is younger then User two!" << "\n";  
         }
         cin.ignore();   
    
}
else if (age_1 && age_2 == >100)

This line does not make sense to me. What are you trying to do here?
else if (age_1 && age_2 = >100)
Wasn't mean't to be ==, just a typo.
If both ages are greater then 100, that's what I'm getting at.

Edit: Am I even close? ><
Last edited on
1) The comparison you are looking for is >= (greater than or equal to)
2) You can't compare multiple values like that; you must do them separately:

else if (age_1 >= 100 && age_2 >= 100)
Thanks for the help mate, you're a legend.
Topic archived. No new replies allowed.