in Programming in C retagged by
350 views
5 votes
5 votes

What will be output printed by the following program?

#include<stdio.h>
main()
{
    int c=4;
    switch(c)
    {
        c=c-1;

        case 4:
            printf("IITB ");
            break;
        default:
            printf("IISc ");
        case 3:
            printf("IITM ");
        case 2 :
            printf("IITD");
    }
}
  1. $\text{IITB IITM}$
  2. $\text{IITB IISc IITM}$
  3. $\text{IITB}$
  4. $\text{IITB IITM IITD}$
in Programming in C retagged by
350 views

1 comment

$ \large{\colorbox{yellow}{Detailed video solution of this question with direct time stamp}}$

All India Mock Test 4 - Solutions Part 1

0
0

1 Answer

1 vote
1 vote
The switch keyword focuses only on the expression/value inside the parentheses ().

After reading the value it will directly jump into the cases part and find the matching. If no matches are found then it will move to the default.

so simply c = c-1 is not even executed it is just ignored.
Answer:

Related questions