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 * );- AA function that takes an integer pointer as argument and returns an integer
- BA function that takes an integer as argument and returns an integer pointer
- CA pointer to a function that takes an integer pointer as argument and returns an integerCorrect answer
- DA 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.