Pointers Questions and Answers

Practice Mode
Showing 10 of 217 questions
Q111
void display (int *list) {printf ("element =        %d\n", *(list + 3)); } int main ( ) { int ary [3] [3] = {{0}, {2, 3}, {4, 5, 6}}; display ((int *) ary); return 0; } What will be printed when the sample code above is executed ?
  • A element = 0
  • B element = 2
  • C element = 3
  • D element = 4
Answer: Option B
Q112
#include <math.h> static double (*funcs [] ) ( double ) = { sin, cos, tan, asin, acos, atan, sinh, cosh, tanh }; double compute Trig Function (int index, double argument) { return ????; } Referring to the sample code above, which should compute the value of a trigonometric function based on its index, what would be a replacement for the ???? to make the correct call ?
  • A (*funcs) [ index ] (argument)
  • B funcs [index] (argument)
  • C funcs (argument) [index]
  • D *funcs [index] (argument)
Answer: Option B
Q113
float (*f[5]()); This declaration represents
  • A pointer to function returning array of float
  • B pointer to array of pointer to function returning float
  • C array of pointers to function returning array of float
  • D array of pointers to function returning float
Answer: Option D
Q114
float (*f( ) ) [5]; This declaration represents
  • A function returningg a pointer to the array of float
  • B pointer to function returning array of float
  • C array to function returning float
  • D all of the above
Answer: Option A
Q115
char (*(*f()[]) (); This pointer declaration represents
  • A function returning array of pointer to a function
  • B pointer to array of pointer to a function return char
  • C function returning a pointer to array of pointer to a function returning char
  • D function returning a pointer to returning char
Answer: Option A
Q116
float (*(*[5])()[10]; This declaration represents
  • A array [5] of function returning a pointer to array [10]of float
  • B array of pointer returning pointer to array [10] of float
  • C array [5] of pointer to a function returning a pointer to array [10] of float
  • D none
Answer: Option C
Q117
# include <stdio.h> char *format = "%d"; int main ( ) { int x; void func ( ) ; func ( scanf, &X ); printf  ("%D\n", x ); return 0; } Referring to the sample code above, which of the following would be a correct implementation for func ?
  • A void func ( int *y (const char*, ... ), int *x ) { (*y) ( format, &x) ; }
  • B void func ( int (*y) const char*, ...), int*x) { (*y) (format , x); }
  • C void func ( int (*y) (const char *, ...), int *x) { (*y) (format, &X ); }
  • D void func ( ( int *) y (const char *, ... ), int *x) {(*y) (format, x ); }
Answer: Option B
Q118
In the declaration int x[3][2][2] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; *(*(*(x+2) +1) +1) represents
  • A the element 13
  • B the element 9
  • C the address of the element of 8
  • D the address of the element of 9
Answer: Option A
Q119
int a = 1; b = 2; c = 3; *pointer; pointer = &c; a = c/*pointer; b = c; printf ("a=%d b=%d", a,b); What will be the output?
  • A a=1 b=3
  • B a=3 b=3
  • C 3 2
  • D Error
Answer: Option D
Q120
void fn (int *a, int *b) { int *t; t=a; a = b; b=t; } main ( ) { int a = 2; void fn ( ); int b=3; fn (&a, &b); printf ("%d %d\n", a, b); } What will be the output ?
  • A Error at runtime
  • B Compilation error
  • C 2 3
  • D 3 2
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test