C Questions March 18, 2023 | No Comments 0 votes, 0 avg 666 123456789101112131415 C Questions 1 / 15 1. Array sizes are optional during array declaration by using ______ keyword. A. auto B. static C. extern D. register 2 / 15 2. What will be the output of the following C code? #include void foo(int *ary[]); int main() { int ary[2][3]; foo(ary); } void foo(int *ary[]) { int i = 10, j = 2, k; ary[0] = &i; ary[1] = &j; *ary[0] = 2; for (k = 0;k < 2; k++) printf("%dn", *ary[k]); } A. 2 2 B. Compile time error C. Undefined behaviour D. 10 2 3 / 15 3. scanf() is a predefined function in______header file. A. stdlib. h B. ctype. h C. stdio. h D. stdarg. h 4 / 15 4. 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 5 / 15 5. The syntax of the scanf() is scanf(“control string “, arg1,arg2,arg3,….,argn); the prototype of control string is ____________ A. [=%[width][modifiers]type=] B. [=%[modifiers][width]type=] C. [=%[width] [modifiers]] D. [width][modifiers] 6 / 15 6. What is an example of iteration in C? A. for B. while C. Do-while D. All of these 7 / 15 7. 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 8 / 15 8. 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 9 / 15 9. What will be the output of the following C code? #include #include int main() { char line[3]; FILE *fp; fp = fopen("newfile.txt", "r"); while (fgets(line, 3, fp)) fputs(line, stdout); return 0; } A. Compilation error B. Infinite loop C. Segmentation fault D. No.of lines present in file newfile 10 / 15 10. 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 11 / 15 11. Which of the following is true about return type of functions in C? A. Functions can return any type B. Functions can return any type except array and functions C. Functions can return any type except array, functions and union D. Functions can return any type except array, functions, function pointer and union 12 / 15 12. 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 13 / 15 13. Multiple values of the same variable can be tested using ___. A. switch B. for C. function D. All of these 14 / 15 14. Which is correct with respect to the size of the data types? A. char > int > float B. int > char > float C. char < int < double D. double > char > int 15 / 15 15. The standard header _______ is used for variable list arguments (…) in C. A. stdio.h B. stdlib.h C. math.h D. stdarg.h Your score isThe average score is 39% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz