0

This is ternary operator 1st condition is true i=0 and true value is 1 but why the output show 3 . Explain?

int i=0; cout<<(i=0?1:2?3:4);

16th Sep 2020, 12:08 PM
Suparna Podder
Suparna Podder - avatar
3 Answers
+ 13
Since i=0.. comparison false.. then goes for 2 Comparison of 2 with 0 ..true hence prints 3
16th Sep 2020, 12:39 PM
Aditya
Aditya - avatar
+ 2
Where its true i=0 and represent false next condition will check 2 non zero which will give result true so Output will be 3
16th Sep 2020, 12:13 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
đŸ—ĄïžJasprit why check false condition?
16th Sep 2020, 12:15 PM
Suparna Podder
Suparna Podder - avatar