Home / C Programming / Control Structures :: Discussion

Discussion :: Control Structures

  1. What will be the following code's output if choice = 'R'?

    switch(choice)

    {

    case 'R' : printf("RED");

    case 'W' : printf("WHITE");

    case 'B' : printf("BLUE");

    default : printf("ERROR");break;

    }

  2. A.

     RED

    B.

     RED WHITE BLUE ERROR

    C.

     RED ERROR

    D.

     RED WHITE BLUE

    E.

     ERROR

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    As the first option is matching, the cases are evaluated till the break statement is encountered or end of switch statement is encountered.


Be The First To Comment