Difficulty: Medium
Correct Answer: XXXXXIndiaBBBBB
Explanation:
Introduction / Context:The snippet mixes switch and if/else to print characters across a numeric range. We must track control flow for negative, zero, and positive values.
Given Data / Assumptions:
Concept / Approach:Count how many times each branch fires: negatives produce X, zero prints India, positives produce B.
Step-by-Step Solution:
Values -5, -4, -3, -2, -1 → five negatives → prints "X" five times.Value 0 → matches case 0 → prints "India".Values 1, 2, 3, 4, 5 → five positives → prints "B" five times.Concatenate in loop order: "XXXXX" + "India" + "BBBBB".Verification / Alternative check:Mental simulation or quick run confirms the exact sequence.
Why Other Options Are Wrong:
Common Pitfalls:Assuming if/else executes before switch or miscounting loop bounds.
Final Answer:XXXXXIndiaBBBBB
Discussion & Comments