Posts

Showing posts from June, 2017

Practice - 4

What is the output of below code fragment ?  #include <stdio.h> #include <string.h> void *x(char *p1, char *p2); int main() {         char *s, *d;         strcpy (s, "hello");         x(s, d);         return 0; } void *x(char *p1, char *p2) {         void *t = p2;         while (*p2++ = *p1++);         return t; }

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.