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

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

void fun()

{

/* .... */

}

Answer: B. Function can be called with any number of parameters of any typesConcept: In ISO C, an empty parameter list "()" inside a function's parentheses is not the same as the explicit no-argument form "(void)". Unlike C++, where…

  1. A.

    Function can only be called without any parameter

  2. B.

    Function can be called with any number of parameters of any types

  3. C.

    Function can be called with any number of integer parameters.

  4. D.

    Function can be called with one integer parameter.

Attempted by 38 students.

Show answer & explanation

Correct answer: B

Concept:

In ISO C, an empty parameter list "()" inside a function's parentheses is not the same as the explicit no-argument form "(void)". Unlike C++, where an empty list always means "no parameters", a bare "()" in C does not establish a parameter-type prototype, so the compiler keeps no record of how many arguments, or of what type, the function expects.

Application:

For void fun() { /* .... */ }, no prototype is generated for fun. Because the compiler never records the parameter count or types, a later call such as fun(1, 2.5, "x") is accepted without a compile-time mismatch error - the empty list behaves as "unspecified parameters", not as "zero parameters". To force the compiler to reject arguments at every call site, the function must instead be written as void fun(void) { ... }, which does create a genuine zero-parameter prototype.

Cross-check:

This matches the option stating the function can be called with any number of parameters of any type, and is the opposite of C++, where void fun() and void fun(void) are identical and both forbid arguments - a classic C-vs-C++ interview trap. (Note: the ISO C standard technically ties this behaviour to whether the empty list appears in a function definition or a mere declaration; virtually every exam and interview treatment of void fun(){...} - as here - uses the simplified "no prototype => unspecified parameters" rule.)

  • "Function can only be called without any parameter" describes void fun(void), which does generate a zero-parameter prototype - not the bare void fun() form shown here.

  • "Function can be called with any number of integer parameters" wrongly narrows the unspecified list to a single type; no such type restriction exists.

  • "Function can be called with one integer parameter" wrongly fixes both the count (one) and the type (integer), neither of which the empty list specifies.

Explore the full course: C Language

Loading lesson…