← Quiz: C Functions and Recursion: all 10 questions
Quiz: C Functions and Recursion · Question 6 of 10
Why do you write a function prototype like int add(int a, int b); above main?
Why do you write a function prototype like int add(int a, int b); above main?
- A.To make the function run faster
- B.So the compiler knows the return type and parameter types when main calls a function defined later
- C.To make the function global
- D.Prototypes are only needed for recursive functions
Answer & explanation
Correct answer: So the compiler knows the return type and parameter types when main calls a function defined later
Without a declaration before the call, the compiler cannot check the call against the function.
Can you get the rest right without peeking?
Take the timed Quiz: C Functions and Recursion quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →