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
