C Questions March 18, 2023 | No Comments 0 votes, 0 avg 641 123456789101112131415 C Questions 1 / 15 1. 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 2 / 15 2. How are String represented in memory in C? A. An array of characters B. The object of some class C. same as other primitive data types D. linkedList of chracters 3 / 15 3. The standard header _______ is used for variable list arguments (…) in C. A. stdio.h B. stdlib.h C. math.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. 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 6 / 15 6. 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 7 / 15 7. 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 8 / 15 8. 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); 9 / 15 9. What is an example of iteration in C? A. for B. while C. Do-while D. All of these 10 / 15 10. What is the use of symbol * in the control string as shown [=%[*][width] [modifiers] type=]? A. * is not optional, used to read data from the stream but it is not ignored B. * is optional and used when the data should be read from the stream but ignored C. * is not optional, it is used to read data stream but ignored D. * is optional and used to read data from stream but it is not ignored 11 / 15 11. 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 12 / 15 12. 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 13 / 15 13. 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 14 / 15 14. 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 15 / 15 15. 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 Your score isThe average score is 39% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz