?
What is the output of the following code: cout << (5 > 2) ? "True" : "False";
Answer & Solution
Correct Answer:
Option
A
The given code uses the ternary operator to evaluate a condition and print a result based on that evaluation.
The code is:
The expression
When the condition is true, the ternary operator returns the first value after the question mark (?). In this case, it returns
Therefore, the correct output of the code is True.
Correct Answer: Option A: TRUE
The code is:
cout << (5 > 2) ? "True" : "False";The expression
(5 > 2) evaluates to true because 5 is greater than 2.When the condition is true, the ternary operator returns the first value after the question mark (?). In this case, it returns
"True".Therefore, the correct output of the code is True.
Correct Answer: Option A: TRUE
Join the Discussion
Login to post a comment or share your explanation.
Login