To solve this question, the user needs to know about Conditional (ternary) Operator.
The conditional operator (also known as the ternary operator) is a shorthand way of expressing a conditional statement. It takes three operands and is denoted as condition ? true_expression : false_expression
. The condition is evaluated first, and if it is true, the expression before the colon (:) is evaluated and its value is returned. If the condition is false, the expression after the colon is evaluated and its value is returned.
In the given statement, x
is assigned the value of a
if a
is greater than b
, and b
otherwise.
Now let's substitute the given values of a
and b
:
x = (a > b) ? a : b
x = (18 > 27) ? 18 : 27
Since 18 is not greater than 27, the condition a > b
is false and x
is assigned the value of b
, which is 27.
Therefore, the statement "x = (a > b) ? a : b; then the value of x is 27, if a = 18 and b = 27" is true.
The Answer is: A