What does the following C-statement declare?int (*f) (int *);a)A funct...
int (*f) (int*);
return type int, (*f) is a pointer to a function the argument is (int*) an integer pointer So, int (*f) (int*) means a pointer to a function that takes an integer pointer as an argument and returns an integer.
View all questions of this test
What does the following C-statement declare?int (*f) (int *);a)A funct...
Explanation:
The given C statement is:
int (*f) (int *);
Let's break down the statement and understand its meaning:
int (*f) - This declares a pointer named 'f' to a function.
(int *) - This specifies that the function takes an integer pointer as an argument.
Therefore, the declaration int (*f) (int *) specifies that 'f' is a pointer to a function that takes an integer pointer as an argument.
Visual representation:
int (*f) (int *);
Here, 'f' is a pointer to a function.
Explanation of each option:
a) A function that takes an integer pointer as an argument and returns an integer:
This option is incorrect because the statement does not declare a function, but rather a pointer to a function.
b) A function that takes an integer pointer as an argument and returns an integer pointer:
This option is incorrect because the statement does not specify that the function returns an integer pointer, but rather an integer.
Correct answer:
c) A pointer to a function that takes an integer pointer as an argument and returns an integer:
This option is correct because the statement declares a pointer 'f' to a function that takes an integer pointer as an argument and returns an integer.
d) A function that takes an integer pointer as an argument returns a function pointer:
This option is incorrect because the statement does not declare a function that returns a function pointer, but rather a pointer to a function that returns an integer.
Summary:
The given C statement 'int (*f) (int *)' declares a pointer 'f' to a function that takes an integer pointer as an argument and returns an integer.