Functions & Parameter Passing MCQs

10 MCQs  — Fundamental Programming MCQs

Practice Functions & Parameter Passing MCQs with correct answers and explanations. These questions are from the Fundamental Programming MCQs section.

Which declaration of default arguments is valid in C++?
void f(int a, int b = 2, int c);
void f(int a, int b = 2, int c = 3);
void f(int a = 1, int b, int c);
void f(int a = 1, int b, int c = 3);
Can two C++ functions be overloaded if they differ only in their return type, as in int f(int) and double f(int)?
Yes, but only for virtual functions
Yes, the compiler picks one based on the assignment target
No, it is a compilation error
Yes, if both are inline
What does the inline keyword on a C++ function guarantee?
Nothing about inlining; it is only a hint, though it does permit multiple identical definitions across translation units
Recursive functions become iterative
The call is always replaced by the function body
The function runs faster
In C, which statement about passing an array to a function is correct?
Only a pointer to the first element is passed, so the function can modify the original array
Arrays cannot be passed to functions
A full copy of the array is passed
The array's size is passed automatically