Vidyalelo
C++ Programming · Q10

Introduction to C++

Programming · C++ Programming · question 10

Q10

What is the output of the following code: cout 2) ? "True" : "False";

A.
TRUE
Answer
B.
FALSE
C.
5
D.
2

Answer: Option A

Solution

Answer: Option A
Solution:
The given code uses the ternary operator to evaluate a condition and print a result based on that evaluation.

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