ExamVeda
Login
Home
This question belongs to C Program C Fundamentals
C Fundamentals
?

What is the primary purpose of a function prototype in C?

Answer & Solution
Correct Answer: Option B
The primary purpose of a function prototype in C is to declare a function. It serves as a forward declaration of the function, providing information about the function's name, return type, and the types of its parameters. This declaration allows the compiler to understand how the function should be called and used in the program before the actual function definition is encountered.

So, the correct answer is:
Option B: Declare a function

In C, a function prototype typically looks like this:

return_type function_name(parameter_type1, parameter_type2, ...);

Here's an example:
int add(int a, int b);

This prototype informs the compiler that there's a function named "add" that returns an integer and takes two integer parameters. It doesn't define the function's implementation; it simply declares its existence and signature.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.