C Questions March 18, 2023 | No Comments 0 votes, 0 avg 234 123456789101112131415 C Questions 1 / 15 1. What will be the output of the following C code? #include int main() { float x = 21.0; x %= 3.0; printf("%f",x); return 0; } A. 7 B. 7.oo C. 7.oooooo D. error 2 / 15 2. What will be the output of the following code snippet? #include void solve() { int a[] = {1, 2, 3, 4, 5}; int sum = 0; for(int i = 0; i < 5; i++) { if(i % 2 == 0) { sum += *(a + i); } else { sum -= *(a + i); } } printf("%d", sum); } int main() { solve(); return 0; } A. 2 B. 15 C. syntax error D. 3 3 / 15 3. What will be the output of the following C code? #include void main() { double k = 0; for (k = 0.0; k < 3.0; k++) printf("Hello"); } A. Run time error B. Hello is printed thrice C. Hello is printed twice D. Hello is printed infinitely 4 / 15 4. 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 5 / 15 5. What is the output of C Program.? int main() { int a=14; while(a<20) { ++a; if(a>=16 && a<=18) { continue; } printf("%d ", a); } return 0; } A. 15 16 17 18 19 B. 15 18 19 C. 15 19 20 D. 15 16 20 6 / 15 6. Which of the following is an exit controlled loop? A. While loop B. for loop C. Do-while loop D. none of the above 7 / 15 7. scanf() is a predefined function in______header file. A. stdlib. h B. ctype. h C. stdio. h D. stdarg. h 8 / 15 8. What will be the output of the following code snippet? #include void solve() { int first = 10, second = 20; int third = first + second; { int third = second - first; printf("%d ", third); } printf("%d", third); } int main() { solve(); return 0; } A. 10 30 B. 30 10 C. 10 20 D. 20 10 9 / 15 9. What will fopen will return, if there is any error while opening a file? A. Nothing B. EOF C. NULL D. Depends on compiler 10 / 15 10. What will be the output of the following C code? #include int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %dn", PEACH); } A. PEACH = 3 B. PEACH = 4 C. PEACH = 5 D. PEACH = 6 11 / 15 11. What does the following program print? #include void f(int *p, int *q) { p = q; *p = 2; } int i = 0, j = 1; int main() { f(&i, &j); printf("%d %d n", i, j); getchar(); return 0; } A. 2 2 B. 2 1 C. 0 1 D. 0 2 12 / 15 12. The standard header _______ is used for variable list arguments (…) in C. A. stdio.h B. stdlib.h C. math.h D. stdarg.h 13 / 15 13. Is initialisation mandatory for local static variables? A. Yes B. No C. Depends on the compiler D. Depends on the standard 14 / 15 14. 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 15 / 15 15. 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 Your score is The average score is 30% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz