🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.To make the function run faster
  2. B.So the compiler knows the return type and parameter types when main calls a function defined later
  3. C.To make the function global
  4. 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 →