41. match the conditional expression with the if/else statement that performs the same operation.\na) q = x…

41. match the conditional expression with the if/else statement that performs the same operation.\na) q = x < y? a + b : x * 2;\nb) q = x < y? x * 2 : a + b;\nc) x < y? q = 0 : q = 1;\nif (x < y)\n q = 0;\nelse\n q = 1;\nif (x < y)\n q = a + b;\nelse\n q = x * 2;\nif (x < y)\n q = x * 2;\nelse\n q = a + b;
Answer
Explanation:
Step1: Analyze the first if - else statement
The first if - else statement is if (x < y) q = 0; else q = 1;. In conditional expression form, it is x < y? q = 0 : q = 1, which matches option C.
Step2: Analyze the second if - else statement
The second if - else statement is if (x < y) q = a + b; else q = x * 2;. In conditional expression form, it is q = x < y? a + b : x * 2, which matches option A.
Step3: Analyze the third if - else statement
The third if - else statement is if (x < y) q = x * 2; else q = a + b;. In conditional expression form, it is q = x < y? x * 2 : a + b, which matches option B.
Answer:
First blank: C Second blank: A Third blank: B