0

How do I solve this

cout <<((1>2)?3:4)

28th Feb 2019, 2:36 PM
Alexandre Meesen
Alexandre Meesen - avatar
5 odpowiedzi
+ 5
Please review ternary operator and remember to use the search bar before posting to avoid duplicates. http://www.cplusplus.com/forum/articles/14631/
28th Feb 2019, 2:44 PM
dρlυѕρlυѕ
dρlυѕρlυѕ - avatar
+ 1
(1>2) is a condition if it is true then the output will be 3. if it is false the output will be 4.
28th Feb 2019, 2:42 PM
Ali
Ali - avatar
0
What this does is checking if 1 is bigger than 2. If it is, 3 is being printed, if not, 4 is printed. 1 is obviously smaller than 2, so 4 is being printed.
28th Feb 2019, 2:40 PM
Jonas Schröter
Jonas Schröter - avatar
0
thanks and what does the ? stand for
28th Feb 2019, 2:44 PM
Alexandre Meesen
Alexandre Meesen - avatar
0
It is a part of that expression, after it there follows what should happen if the condition is true
28th Feb 2019, 2:48 PM
Jonas Schröter
Jonas Schröter - avatar