Which of the following is the correct way to declare a function in C?
A.
return-type function-name(argument-type);
B.
return-type function-name(argument-type){}
C.
return-type (argument-type)function-name;
D.
function-name(argument-type) return-type;
Which of the following can a C function NOT return directly?
A.
struct
B.
int
C.
void
D.
Another function
What is the purpose of a function prototype?
A.
To define the logic of the function.
B.
To tell the compiler the function's name, return type, and parameters before it is called.
C.
To call the function from main().
D.
To allocate memory for the function's variables.
In a function definition like void add(int x, int y), what are x and y called?
A.
Actual parameters
B.
Formal parameters
C.
Global variables
D.
Constants
What is the "base case" in a recursive function?
A.
The case where the function calls itself.
B.
The case that stops the recursion to prevent an infinite loop.
C.
The first line of the function.
D.
The main() function.
What will be the output of this code?
void m() {
static int x = 3;
x++;
if (x <= 5) {
printf("%d ", x);
m();
}
}
int main() {
m();
return 0;
}
A.
4 5
B.
3 4 5
C.
4 4 4
D.
Infinite loop
What happens if a recursive function lacks a base case?
A.
The program compiles but crashes with a "Stack Overflow" error.
B.
The compiler identifies it as an error and won't build the file.
C.
The function executes only once.
D.
The return value becomes 0