What does it mean when we mention prototype of a function in C language?
2017
What does it mean when we mention prototype of a function in C language?
- A.
Prototyping
- B.
Calling
- C.
Declaring
- D.
Defining
Attempted by 379 students.
Show answer & explanation
Correct answer: C
In C, before a function is used the compiler needs to know its interface — the function's name, return type, and the type of every parameter it takes. A statement that specifies this interface without supplying the function's body is a function declaration; when that declaration also lists the parameter types (not just the count), it is specifically called a function prototype, as defined in the ISO C standard (C11, sections 6.2.1 and 6.7.6.3).
So mentioning or writing out a function's prototype in source code — stating its return type, name, and parameter types ahead of its use — is exactly the act of declaring that function to the compiler. That is why the correct answer is "Declaring."
Prototyping — not a distinct C-language construct or standard term for this act; C programmers and the ISO standard both describe writing the prototype as declaring the function.
Calling — happens later, when control and the argument values are handed to an already declared (or defined) function so its code actually runs; mentioning the prototype alone does not run anything.
Defining — requires supplying the function's body (the code inside { }); a prototype has no body, so writing one cannot be defining the function.
This also matches how C allows a function to be declared (via its prototype) any number of times across different files before it is defined exactly once — the prototype's entire job is to state the interface, which is precisely what "declaring" means.