Skip to content
Official PYQ · 2005

GATE CS 2005 Q1 — Programming in C

Explain with AI

What does the following C-statement declare?

int (*f) (int * );
Choose one option
View worked solution

Answer: C

We can decode the C declaration int (*f) (int *); using the operator precedence rules (or the spiral rule) for C declarations:

  1. Identify the identifier: Start with the variable name, which is f.
  2. Check parentheses: Inside the parentheses, we have *f. The asterisk (*) indicates that f is a pointer.
  3. Look to the right: Outside the parentheses on the right, we see (int *). This indicates that f points to a function taking an int * (pointer to an integer) as its argument.
  4. Look to the left: On the far left, we have the return type int. This means the function returns an integer.

Combining these steps, f is a pointer to a function that takes an integer pointer as an argument and returns an integer.

Therefore, the correct option is C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Programming in C questions