Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C code? #include <stdio.h> void f(int (*x)(int)); int myfoo(int i); int (*foo)(int) = myfoo; int main() { f(foo(10)); } void f(int (*i)(int)) { i(11); } int myfoo(int i) { printf("%d\n", i); return i; }
Q2
What will be the output of the following C code? #include <stdio.h> void f(int (*x)(int)); int myfoo(int); int (*fooptr)(int); int ((*foo(int)))(int); int main() { fooptr = foo(0); fooptr(10); } int ((*foo(int i)))(int) { return myfoo; } int myfoo(int i) { printf("%d\n", i + 1); }
Q3
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0, j = 1; int *a[] = {&i, &j}; printf("%d", *a[0]); return 0; }
Q4
What will be the output of the following C code? #include <stdio.h> struct student { int no = 5; char name[20]; }; void main() { struct student s; s.no = 8; printf("hello"); }
Q5
Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0;)?
Q6
What will be the output of the following C code? #include <stdio.h> void f(int); void (*foo)(void) = f; int main(int argc, char *argv[]) { foo(10); return 0; } void f(int i) { printf("%d\n", i); }
Q7
What will be the output of the following C code? #include <stdio.h> int main() { int ary[4] = {1, 2, 3, 4}; int *p = ary + 3; printf("%d %d\n", p[-2], ary[*p]); }
Q8
What will be the output of the following C code (run without any command line arguments)? #include <stdio.h> int main(int argc, char *argv[]) { printf("%s\n", argv[argc]); return 0; }
Q9
Which of the following is a correct syntax to pass a Function Pointer as an argument?
Q10
What type of initialization is needed for the segment "ptr[3] = '3';" to work?
Q11
What will be the output of the following C code? #include <stdio.h> void m(int p, int q) { printf("%d %d\n", p, q); } void main() { int a = 6, b = 5; m(a); }
Q12
What will be the output of the following C code? #include <stdio.h> int main() { int *ptr, a = 10; ptr = &a; *ptr += 1; printf("%d,%d/n", *ptr, a); }
Q13
What will be the output of the following C code? #include <stdio.h> void fun(char *k) { printf("%s", k); } void main() { char s[] = "hello"; fun(s); }
Q14
What will be the output of the following C code? #include <stdio.h> void main() { char *s = "hello"; char *p = s; printf("%c\t%c", *(p + 1), s[1]); }
Q15
Comment on the following two operations. int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1 int b[][] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 2
Q16
What will be the output of the following C code? #include <stdio.h> void m(int p, int q) { int temp = p; p = q; q = temp; } void main() { int a = 6, b = 5; m(a, b); printf("%d %d\n", a, b); }
Q17
What will be the output of the following C code? #include <stdio.h> void main() { int k = 5; int *p = &k; int **m = &p; printf("%d%d%d\n", k, *p, **m); }
Q18
Which directive is used to include the contents of another file in a C program using the C preprocessor?
Q19
What will be the output of the following C code? #include <stdio.h> int *f(); int main() { int *p = f(); printf("%d\n", *p); } int *f() { int *j = (int*)malloc(sizeof(int)); *j = 10; return j; }
Q20
What will be the output of the following C code? #include <stdio.h> int main() { double *ptr = (double *)100; ptr = ptr + 2; printf("%u", ptr); }
Q21
What will be the output of the following C code? #include <stdio.h> void main() { struct student { int no; char name[20]; }; struct student s; s.no = 8; printf("%s", s.name); }
Q22
What is the purpose of the #define directive in C preprocessing?
Q23
What is the purpose of the C preprocessor in C programming?
Q24
Calling a function f with a an array variable a[3] where a is an array, is equivalent to . . . . . . . .
Q25
What type of array is generally generated in Command-line argument?