C Questions March 18, 2023 | No Comments 0 votes, 0 avg 581 123456789101112131415 C Questions 1 / 15 1. The following function computes the maximum value contained in an integer array p[] of size n (n >= 1) int max(int *p, int n) { int a=0, b=n-1; while (__________) { if (p[a] <= p[b]) { a = a+1; } else { b = b-1; } } return p[a]; } The missing loop condition is A. a != n B. b != O C. b > (a+1) D. b != a 2 / 15 2. What will be the output of the following C code? #include int main() { const int ary[4] = {1, 2, 3, 4}; int *p; p = ary + 3; *p = 5; printf("%dn", ary[3]); } A. 4 B. 5 C. Compile time error D. 3 3 / 15 3. 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 4 / 15 4. What will be the output of the following C code? #include void main() { char *s = "hello"; char *p = s * 3; printf("%ct%c", *p, s[1]); } A. h e B. l e C. Compile time error D. l h 5 / 15 5. 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); 6 / 15 6. Which C keyword is used to extend the visibility of variables? A. extend B. extends C. extern D. auto 7 / 15 7. What is the output of C Program.? int main() { int a=10,b=20; if(a==9 AND b==20) { printf("Hurray.."); } if(a==10 OR b==21) { printf("Theatre"); } return 0; } A. Theatre B. Hurray Theatre C. No output D. Compiler error 8 / 15 8. 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 9 / 15 9. 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] 10 / 15 10. What will be the output of the following C code? #include int main() { char str1[] = { 'H', 'e', 'l', 'l', 'o' }; char str2[] = "Hello"; printf("%ld,%ld", sizeof(str1), sizeof(str2)); return 0; } A. 5,5 B. 6,6 C. 5,6 D. None of the above 11 / 15 11. Which of the following is true for the static variable? A. It can be called from another function B. It exists even after the function ends C. It can be modified in another function by sending it as a parameter D. All of the mentioned 12 / 15 12. 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 13 / 15 13. In C, parameters are always A. Passed by value B. Passed by reference C. Non-pointer variables are passed by value and pointers are passed by reference D. Passed by value result 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. Which of the following are themselves a collection of different data types? A. string B. structures C. char D. all of the mentioned Your score is The average score is 40% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz