Advertisements
Advertisements
प्रश्न
Read the
if program segment given below:if(a>b)
z = 25;
else
z = 35;
Which one of the following is the correct conversion of the if program segment to ternary?पर्याय
z = a > b ? 35 : 25;z = a > b ? 25 : 35;z = a > b : 35 ? 25;z = a > b : 25 ? 35;
MCQ
Advertisements
उत्तर
z = a > b ? 25 : 35;
Explanation:
The ternary operator works in this format:
condition ? expression_if_true : expression_if_false;- Condition:
a > b - True value: In your code, if the condition is true,
zbecomes25. - False value: If the condition is false (
else),zbecomes35.
Putting it together: z = a > b ? 25 : 35;
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2025-2026 (March) Official Board Paper
