ProgrammingVery hardProduct company OA · GATE CS

Given int f(int); and int (*fp)(int) = f; which of these calls are valid? (i) fp(2) (ii) (*fp)(2) (iii) (**fp)(2) (iv) (&fp)(2)

  1. A. (i), (ii) and (iii) only
  2. B. (i) and (ii) only
  3. C. All four
  4. D. (ii) only

Correct answer: A. (i), (ii) and (iii) only

Dereferencing a function pointer gives a function designator, which immediately decays back into a pointer, so any number of * still calls f. &fp, however, is a pointer to the pointer variable, int (**)(int), which cannot be called.

More C Programming questions

Exams that ask this topic