Ask Question
18 November, 13:52

What is x after evaluating?

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

A. 2

B. 3

C. 4

D. none of the above

+4
Answers (1)
  1. 18 November, 14:14
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers