What will be the value of p after the following code execution?
int p = 1 > 2 ? (3 > 3 ? 1 : 2) : (3 < 3 ? 3 : 4);
Explanation
The basic syntax of using the ternary operator is thus:
(condition) ? (if_true) : (if_false)
Which is basically the same as:
if (condition)
    if_true;
else
    if_false;

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes