Solution
The correct answer is int (*func) (int, int);
Explanation:
To declare a function pointer in C, the correct syntax must be followed. A function pointer is a variable that stores the address of a function, and the declaration involves specifying the return type of the function, the pointer itself, and the types of its parameters.
Analyzing the Options:
- int *func (int, int);
- This declares a function named func that returns a pointer to an integer. It is not a function pointer declaration.
- int (*func) (int, int);
- This is the correct declaration of a function pointer. It declares func as a pointer to a function that takes two int parameters and returns an int.
- int (func*) (int, int);
- This is incorrectly formatted. The placement of the asterisk is not valid in this context.
- int *func* (int, int);
- This is also incorrectly formatted and does not follow the syntax for a function pointer declaration.
Conclusion:
The correct way to declare a function pointer in C is: 2) int (*func) (int, int);.