0

what do these operators mean?

I saw this code: int a; a=5>4?3>8?40:20:30; cout<<a; and the result was 20. i don't know the operators "?" ":", and what do they mean, and what they do in that contest. thanks.

23rd Jul 2020, 3:51 PM
‎Mmk
‎Mmk - avatar
2 odpowiedzi
+ 3
a>b?c:d means: if(a > b) { return c; } else { return d; } 5>4?9>8?40:20:30 means if(5 >4) { if(9>8) { return 40; } else { return 20; } } else { return 30; }
23rd Jul 2020, 3:58 PM
Saphal Poudyal
Saphal Poudyal - avatar
0
it is a puzzle, so unclarity is the idea.
23rd Jul 2020, 4:00 PM
‎Mmk
‎Mmk - avatar