Skip to content
Related Articles

Related Articles

C | Loops & Control Structure | Question 21
  • Difficulty Level : Basic
  • Last Updated : 18 Jan, 2014
GeeksforGeeks - Summer Carnival Banner




#include<stdio.h>
int main()
{
    int a = 5;
    switch(a)
    {
    default:
        a = 4;
    case 6:
        a--;
    case 5:
        a = a+1;
    case 1:
        a = a-1;
    }
    printf("%d \n", a);
    return 0;
}

(A) 3
(B) 4
(C) 5
(D) None of these


Answer: (C)

Explanation: There is no break statement, so first a = a + 1 is executed, then a = a-1 is executed.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :