C | Functions | Question 10
In C, what is the meaning of following function prototype with empty parameter list
void fun() { /* .... */ } |
(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
Please Login to comment...