What is the output of the following code? int switch(i)

20242024

What is the output of the following code?

int i = 5;

switch(i)

{

case 1: printf("One");

case 5: printf("Five");

case 10: printf("Ten");

default: printf("Other");

}

  1. A.

    Five

  2. B.

    Ten

  3. C.

    FiveTen Other

  4. D.

    Other

Attempted by 507 students.

Show answer & explanation

Correct answer: C

In the switch statement, when the case for i=5 is matched, the program will continue to execute all subsequentcases and the default case, as there are no 'break' statements.

Explore the full course: Dsssb Tgt Computer Science Paper 2