Posts

Showing posts with the label Simple Code Fragments

what is the output ?

What is the output if num = 1 ?  #include <stdio.h> int main() {         int i = 1;         switch(i % 10) {                 case 1 : printf ("one \n");                 case 2 : printf ("two \n");                 case 3 : printf ("three \n");         }         return 0; }

What is the output ?

If the break is replaced by continue, what is the output ? #include <stdio.h> int main() {         int i;         for (i = 0 ;; i++) {                 i = i + 2;                 printf ("output : %d\n", i);                 break;         }         return 0; }               Answer : a) No output and program stops. b) No output and programs runs indefinitely.