Gate CS-2015-3 Question Paper With Solutions

Q. 60 Consider the following C program

# include <stdio.h>  int main( )  {     int i, j, k = 0;     j = 2 * 3 / 4 + 2.0 / 5 + 8 / 5;     k  -= --j;     for (i = 0; i < 5; i++)     {        switch(i + k)        {           case 1:           case 2: printf("\n%d", i + k);           case 3: printf("\n%d", i + k);           default: printf("\n%d", i + k);        }     }     return 0;  } 

The number of times printf statement is executed is_______.

(A) 8

(B) 9

(C) 10

(D) 11

Answer: (C)

Explanation:

Gate CS-2015-3 Question Paper With Solutions

Learn More:   Gate EE-2019 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here