Question 1 of 25
Hints left: 3
Q1
What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming declaration int a[5][4][3];)
Q2
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("%d", s.no); }
Q3
What will be the output of the following C code? #include <stdio.h> struct student { int no; char name[20]; }; void main() { student s; s.no = 8; printf("hello"); }
Q4
What will be the output of the following C code? #include <stdio.h> void f(int); void (*foo)() = f; int main(int argc, char *argv[]) { foo(10); return 0; } void f(int i) { printf("%d\n", i); }
Q5
What will be the output of the following C code? #include <stdio.h> int main() { int a = 1, b = 2, c = 3; int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c; int **sptr = &ptr1; //-Ref *sptr = ptr2; }
Q6
What will be the output of the following C code? #include <stdio.h> void (*(f)())(int, float); void (*(*x)())(int, float) = f; void ((*y)(int, float)); void foo(int i, float f); int main() { y = x(); y(1, 2); } void (*(f)())(int, float) { return foo; } void foo(int i, float f) { printf("%d %f\n", i, f); }
Q7
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, s[1]); }
Q8
What will be the output of the following C code? #include <stdio.h> struct student { int no; char name[20]; }; struct student s; void main() { s.no = 8; printf("%s", s.name); }
Q9
What will be the output of the following C code? #include <stdio.h> void main() { char *a[10] = {"hi", "hello", "how"}; int i = 0, j = 0; a[0] = "hey"; for (i = 0;i < 10; i++) printf("%s\n", a[i]); }
Q10
What will be the output of the following C code? #include <stdio.h> void main() { int x = 0; int *ptr = &5; printf("%p\n", ptr); }
Q11
What will be the output of the following C code? #include <stdio.h> void foo(int*); int main() { int i = 10; foo((&i)++); } void foo(int *p) { printf("%d\n", *p); }
Q12
What will be the output of the following C code? #include <stdio.h> int main() { int ary[4] = {1, 2, 3, 4}; printf("%d\n", *ary); }
Q13
What will be the output of the following C code? #include <stdio.h> int main() { char **p = {"hello", "hi", "bye"}; printf("%s", (p)[0]); return 0; }
Q14
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, **p); }
Q15
Comment on the following pointer declaration. int *ptr, p;
Q16
What will be the output of the following C code? #include <stdio.h> void foo(int*); int main() { int i = 10, *p = &i; foo(p++); } void foo(int *p) { printf("%d\n", *p); }
Q17
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; }
Q18
What will be the output of the following C code? #include <stdio.h> void foo(float *); int main() { int i = 10, *p = &i; foo(&i); } void foo(float *p) { printf("%f\n", *p); }
Q19
What will be the output of the following C code? #include <stdio.h> int main() { char *str = "hello, world\n"; char *strc = "good morning\n"; strcpy(strc, str); printf("%s\n", strc); return 0; }
Q20
What will be the output of the following C code? #include <stdio.h> void (*(f)())(int, float); typedef void (*(*x)())(int, float); void foo(int i, float f); int main() { x p = f; p(); } void (*(f)())(int, float) { return foo; } void foo(int i, float f) { printf("%d %f\n", i, f); }
Q21
Which of the following declaration are illegal?
-
A
-
B
-
C
-
D
Q22
What will be the output of the following C code? #include <stdio.h> int add(int a, int b) { return a + b; } int main() { int (*fn_ptr)(int, int); fn_ptr = add; printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3)); }
Q23
What are the elements present in the array of the following C code? int array[5] = {5};
-
A
-
B
-
C
-
D
Q24
What substitution should be made to //-Ref such that ptr1 points to variable c in the following C code? #include <stdio.h> int main() { int a = 1, b = 2, c = 3; int *ptr1 = &a; int **sptr = &ptr1; //-Ref }
Q25
One of the uses for function pointers in C is . . . . . . . .