C Questions March 18, 2023 | No Comments 0 votes, 0 avg 720 123456789101112131415 C Questions 1 / 15 1. What is the return type of the fopen() function in C? A. pointer to a FILE object B. pointer to an integer C. an integer D. a long 2 / 15 2. 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 3 / 15 3. 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 4 / 15 4. What will be the output of the following C program? #include int main() { int x[5] = { 10, 20, 30 }; printf("%ld", sizeof(x)/sizeof(x[0])); return 0; } A. 3 B. 4 C. 5 D. 6 5 / 15 5. 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 6 / 15 6. What will be the output of the following C code? #include void main() { int x = 1, y = 0, z = 5; int a = x && y && z++; printf("%d", z); } A. 6 B. 5 C. Varies D. 0 7 / 15 7. 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 8 / 15 8. What is the output of C Program.? int main() { int a=0, b=0; while(++a < 4) printf("%d ", a); while(b++ < 4) printf("%d ", b); return 0; } A. 0 1 2 3 1 2 3 4 B. 1 2 3 1 2 3 4 C. 1 2 3 4 1 2 3 4 D. 1 2 3 4 0 1 2 3 9 / 15 9. What will be the output of the following C code? #include struct student { int no = 5; char name[20]; }; void main() { struct student s; s.no = 8; printf("hello"); } A. Nothing B. Compile time error C. hello D. Varies 10 / 15 10. Size of an array can be evaluated by __________ (Assuming array declaration int a[10];) A. sizeof(a); B. sizeof(*a); C. sizeof(a[10]); D. 10 * sizeof(a); 11 / 15 11. What will be the final values of i and j in the following C code? #include int x = 0; int f() { if (x == 0) return x + 1; else return x - 1; } int g() { return x++; } int main() { int i = (f() + g()) | g(); //bitwise or int j = g() | (f() + g()); //bitwise or } A. i value is 1 and j value is 1 B. i value is 0 and j value is 0 C. i value is 1 and j value is undefined D. i and j value are undefined 12 / 15 12. If p is an integer pointer with a value 1000, then what will the value of p + 5 be? A. 1020 B. 1005 C. 1004 D. 1010 13 / 15 13. What will be the output of the following C code? #include void main() { int a[2][3] = {1, 2, 3, 4, 5}; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%d", a[i][j]); } A. 1 2 3 4 5 0 B. 1 2 3 4 5 junk C. 1 2 3 4 5 5 D. Run time error 14 / 15 14. scanf() is a predefined function in______header file. A. stdlib. h B. ctype. h C. stdio. h D. stdarg. h 15 / 15 15. What will be the output of the following C program? #include union values { int val1; char val2; } myVal; int main() { myVal.val1 = 66; printf("val1 = %p", &myVal.val1); printf("nval2 = %p", &myVal.val2); return 0; } A. val1 = 0x54ac88dd2012 val2 = 0x55ac76dd2014 B. Error C. val1 = 0x55ac76dd2014 val2 = 0x55ac76dd2014 D. Exception Your score isThe average score is 39% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz