Skip to content

ISRO Scientist/Engineer CSE 2017Programming in C › Pointers and Arrays

ISRO Scientist/Engineer CSE 2017 PYQ: What does the following C-statement declare? int (*f) (int * );

What does the following C-statement declare?

int (*f) (int * );
  1. A
    A function that takes an integer pointer as argument and returns an integer
  2. B
    A function that takes an integer as argument and returns an integer pointer
  3. C
    A pointer to a function that takes an integer pointer as argument and returns an integer
    Correct answer
  4. D
    A function that takes an integer pointer as argument and returns a function pointer

Answer

(C) A pointer to a function that takes an integer pointer as argument and returns an integer

Approach

Parse the declaration using C's operator precedence and the 'declaration mimics use' rule. The parentheses around f bind the to f first, making f a pointer; the trailing (int *) then describes the function it points to.

Reviewed by ISRO IQ Editorial Team.