Enhance your programming skills with the RECF Programming Test. Features flashcards and multiple choice questions with hints and explanations. Prepare for success!

Multiple Choice

Which of the following is a valid function prototype for a function named add that takes two int parameters and returns int?

Function prototypes in C declare how a function can be called: they specify the return type, the function name, and the types of its parameters. For a function named add that takes two int parameters and returns int, the prototype must show a return type of int and two parameters of type int (the parameter names are optional for the prototype). The correct form is int add(int a, int b); This matches both the return type and the parameter types exactly, and the names a and b are just for readability. The other forms fail because they either specify a different return type (void instead of int), omit a parameter type, or omit types for the parameters altogether. So the valid prototype is int add(int a, int b);

Function prototypes in C declare how a function can be called: they specify the return type, the function name, and the types of its parameters. For a function named add that takes two int parameters and returns int, the prototype must show a return type of int and two parameters of type int (the parameter names are optional for the prototype). The correct form is int add(int a, int b); This matches both the return type and the parameter types exactly, and the names a and b are just for readability.

The other forms fail because they either specify a different return type (void instead of int), omit a parameter type, or omit types for the parameters altogether. So the valid prototype is int add(int a, int b);