C Questions March 18, 2023 | No Comments 0 votes, 0 avg 729 123456789101112131415 C Questions 1 / 15 1. 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 2 / 15 2. What is the output of the following code snippet? #include int main() { int a[] = {1, 2, 3, 4}; int sum = 0; for(int i = 0; i < 4; i++) { sum += a[i]; } printf("%d", sum); return 0; } A. 1 B. 4 C. 20 D. 10 3 / 15 3. How many times i value is checked in the following C program? #include int main() { int i = 0; while (i < 3) i++; printf("In while loopn"); } A. 2 B. 3 C. 4 D. 1 4 / 15 4. What is the disadvantage of arrays in C? A. The amount of memory to be allocated should be known beforehand B. Elements of an array can be accessed in constant time C. Elements are stred in contiguous memory blocks D. Multiple other data structures can be implemented using array. 5 / 15 5. 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 6 / 15 6. What will be the output of the following C code? #include int main() { float x = 23.456; printf("%.2f",x); return 0; } A. 23.456OO B. 23.456 C. 23.45 D. 23.46 7 / 15 7. 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 8 / 15 8. 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 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 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 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. The concept of two functions with same name is know as? A. Operator Overloading B. Function Overloading C. Function Overriding D. Function renaming 13 / 15 13. 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] 14 / 15 14. 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 15 / 15 15. Multiple values of the same variable can be tested using ___. A. switch B. for C. function D. All of these 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