if (option ... 2) {

Hello,

I want to make some sort of easter egg in my program once a number is higher then an allowed number. Which code do I use, do I use > or <, since I learned that in math a few years ago.

Eg.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int choice1;

int main(int argc, char *argv[])
cout << "blablabla";
cout << "1. ....";
cout << "2. ....";
cin>> choice1;
if (choice1 == 1) {
cout << "You chose one";
}
if (choice1 == 2) {
cout << "You chose 2";
}

if (choice1 >> 2) { // if higher than 2, does it work like this?
cout << "You choose higher than 2";
}


Thanks,

Darryl
Last edited on

Yes that's how it works.

if (choice1 > 2)

Note, only one '>'


Plus, you could just try both and see which one satisfies your intended logic...
Last edited on
Thank u!
Topic archived. No new replies allowed.