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

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.




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

My Personal Notes arrow_drop_up
Recommended Articles
Page :