Skip to content
Related Articles

Related Articles

Improve Article

C Quiz – 107 | Question 5

  • Difficulty Level : Basic
  • Last Updated : 28 Jun, 2021

For the following declaration of a function in C, pick the best statement




int [] fun(void (*fptr)(int *));

(A) It will result in compile error.
(B) No compile error. fun is a function which takes a function pointer fptr as argument and return an array of int.
(C) No compile error. fun is a function which takes a function pointer fptr as argument and returns an array of int. Also, fptr is a function pointer which takes int pointer as argument and returns void.
(D) No compile error. fun is a function which takes a function pointer fptr as argument and returns an array of int. The array of int depends on the body of fun i.e. what size array is returned. Also, fptr is a function pointer which takes int pointer as argument and returns void.


Answer: (A)

Explanation: As per C standard, a function can’t have an explicit array as return type. That’s why the above would result in compile error. There’re indirect ways if we need an array as an output of a function call. For example, a pointer can be returned by function by return statement while providing the size of array via other means. Alternatively, function argument can be used for this.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :