C Questions March 18, 2023 | No Comments 0 votes, 0 avg 726 123456789101112131415 C Questions 1 / 15 1. What will be the output of the following C code? #include int *m(); void main() { int *k = m(); printf("hello "); printf("%d", k[0]); } int *m() { int a[2] = {5, 8}; return a; } A. Hello 5 8 B. Hello 5 C. hello followed by garbage value D. Compilation error 2 / 15 2. What will be the output of the following C code? #include struct p { int k; char c; float f; }; int p = 10; int main() { struct p x = {1, 97}; printf("%f %dn", x.f, p); } A. Compile time error B. O.OOOOOO 1O C. Somegarbage value 10 D. 0 10 3 / 15 3. What is output of below program? int main() { int i,j,count; count=0; for(i=0; i<5; i++); { for(j=0;j<5;j++); { count++; } } printf("%d",count); return 0; } A. 55 B. 54 C. 1 D. o 4 / 15 4. What will be the output of the following C code? #include int f(char chr, ...); int main() { char c = 97; f(c); return 0; } int f(char c, ...) { printf("%cn", c); } A. Compile time error B. Undefined behaviour C. 97 D. a 5 / 15 5. Which option should be selected to work the following C expression? string p = "HELLO"; A. typedef char [] string; B. typedef char *string; C. typedef char [] string; and typedef char *string; D. Such expression cannot be generated in C 6 / 15 6. What will be the output of the following C code? #include int main() { int a = 1, b = 2, c = 3; int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c; int **sptr = &ptr1; //-Ref *sptr = ptr2; } A. ptr1 points to a B. ptr1 points to b C. sptr points to ptr2 D. none of the mentioned 7 / 15 7. What will be the output of the following C code? #include int main(){ int a = 11; while (a < 20) { printf("%d ", a); a += 2; } return 0; } A. 11 13 15 17 19 B. 11 12 13 14 15 16 17 18 19 20 C. 11 13 15 17 19 21 D. None of these 8 / 15 8. What will be the output of the following C code? #include int main() { int i = 0; do { i++; if (i == 2) continue; printf("In while loop "); } while (i < 2); printf("%dn", i); } A. In while loop 2 B. In while loop in while loop 3 C. In while loop 3 D. Infinite loop 9 / 15 9. What will be the output of the following C code? #include int main() { int x = 0; if (x == 1) if (x == 0) printf("inside ifn"); else printf("inside else ifn"); else printf("inside elsen"); } A. inside if B. inside else if C. inside else D. compile time error 10 / 15 10. What will be the output of this program? int main() { int a=10, b=20; printf("a=%d b=%d",a,b); a=a+b; b=a-b; a=a-b; printf("a=%d b=%d",a,b); return 0; } A. a = 20, b = 20 B. a=10, b=20 C. a=20, b=10 D. a=10, b=10 11 / 15 11. Multiple values of the same variable can be tested using ___. A. switch B. for C. function D. All of these 12 / 15 12. What will be the output of the following C code? #include int main() { printf("%d ", 1); goto l1; printf("%d ", 2); l1:goto l2; printf("%d ", 3); l2:printf("%d ", 4); } A. 1 4 B. compilation error C. 1 2 4 D. 1 3 4 13 / 15 13. What will be the output of the following C function? #include enum birds {SPARROW, PEACOCK, PARROT}; enum animals {TIGER = 8, LION, RABBIT, ZEBRA}; int main() { enum birds m = TIGER; int k; k = m; printf("%dn", k); return 0; } A. 8 B. 1 C. O D. compile time error 14 / 15 14. What will be the output of the following C code? #include void main() { int i = 0; while (i < 10) { i++; printf("hin"); while (i < 8) { i++; printf("hellon"); } } } A. Hi is printed 8 times, hello 7 times and then hi 2 times B. Hi is printed 10 times, hello 7 times C. Hi is printed once, hello 7 times D. Hi is printed once, hello 7 times and then hi 2 times 15 / 15 15. scanf() is a predefined function in______header file. A. stdlib. h B. ctype. h C. stdio. h D. stdarg. h Your score isThe average score is 38% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Written by Shubhranshu Shekhar, who has trained 20000+ students in coding. Kritika Papne Questions, Quiz