Q1
What is the primary purpose of a function prototype in C?
A.
Declare a variable
B.
Declare a function
AnswerC.
Define a function
D.
Assign a value
Answer: Option B
Solution
Answer: Option B
Solution:
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.