Integer comparison

Hello, in this code that I am writing everything works perfectly. Eg

5 + 5 = smaller

35 + 50 = larger

-50 - 35 = larger

etc

But what I want it to do, is that ones I reach below -100 (eg -101 & -102 etc) I want it to display "smaller". Is this possible with current code? Help, I've been going at it for hours... lol.


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
29
30
  #include <iostream>

using namespace std;

int main()
{
    int number;
    int number2;
    int sum;


    cin >> number >> number2;
    sum = number + number2;

    if (sum < 36 && sum > -36)

        cout << "smaller" << endl;

    if (sum == 36)

        cout << "equal" << endl;

    if (sum > 36 || sum < -36)

        cout << "larger" << endl;



    return 0;
}
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
29
30
31
32
33
34
  #include <iostream>

using namespace std;

int main()
{
    int number;
    int number2;
    int sum;


    cin >> number >> number2;
    sum = number + number2;

    if (sum < 36 && sum > -36)

        cout << "smaller" << endl;

    else if (sum == 36)

        cout << "equal" << endl;

    else if (sum > 36 || sum < -36 && sum >= -100)

        cout << "larger" << endl;

    else if (sum < -100)

        cout << "smaller" << endl;



    return 0;
}


that should work
Yes, thank you. It worked.
Topic archived. No new replies allowed.