What is the primary purpose of a function prototype in C?
A. Declare a variable
B. Declare a function
C. Define a function
D. Assign a value
Answer: Option B
Solution(By Examveda Team)
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.
Related Questions on C Fundamentals
What is the primary purpose of a function prototype in C?
A. Declare a variable
B. Declare a function
C. Define a function
D. Assign a value
What is the correct syntax for declaring a variable in C?
A. int variable_name;
B. variable_name = 5;
C. variable_name int;
D. int = variable_name;
Join The Discussion