C | Functions | Question 10

In C, what is the meaning of following function prototype with empty parameter list

filter_none

edit
close

play_arrow

link
brightness_4
code

void fun()
{
   /* .... */
}

chevron_right


(A) Function can only be called without any parameter
(B) Function can be called with any number of parameters of any types
(C) Function can be called with any number of integer parameters.
(D) Function can be called with one integer parameter.


Answer: (B)

Explanation: Empty list in C mean that the parameter list is not specified and function can be called with any parameters. In C, to declare a function that can only be called without any parameter, we should use “void fun(void)”

As a side note, in C++, empty list means function can only be called without any parameter. In C++, both void fun() and void fun(void) are same.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.