Ask Question
5 November, 13:29

What is x after evaluating?

x = (2>3) ? 2 : 3;

A. 2

B. 3

C. 4

D. none of the above

+5
Answers (1)
  1. 5 November, 14:00
    0
    3

    Explanation:

    In programming, there is a lot of conditional operators.

    like NOT (&&) operator, OR (||) operator.

    similarly, there is an operator called the ternary operator. It takes three operands and it behaves like the if-else statement.

    syntax:

    (condition) ? expression 1 : expression 2;

    Working:

    If the condition is true, then it executes the expression 1 and if the condition is false, then it executes the expression 2.

    let see the Question,

    x = (2>3) ? 2 : 3;

    the condition (2 > 3) is false, 2 always less than 3 not greater than 3.

    Therefore, it executes the value 3 and assigns to x.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What is x after evaluating? x = (2>3) ? 2 : 3; A. 2 B. 3 C. 4 D. none of the above ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers