Fundamental Programming MCQs

100 MCQs  (Page 7 of 10)

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
What happens when a recursive Python function has no reachable base case?
RecursionError (maximum recursion depth exceeded)
SyntaxError
It returns None
It loops forever without any error
Does CPython optimize tail-recursive calls (tail-call optimization)?
Only in Python 3.11 and later
No; tail calls still consume stack frames
Yes, always
Yes, when @tailrec is used
Which statement about recursion compared with iteration is correct?
Some problems can only be solved recursively
Recursion is always faster than iteration
Any recursive algorithm can be rewritten iteratively, typically by using an explicit stack
Recursion uses less memory than iteration