Summative #7 Flashcards
What are the mandatory parts of a function declaration?
return type and function name
A function that can be made to return a single value to the calling program.
void
The program that calls a function is often referred to as the calling program.
True
Recursion is a method in which the solution of a problem depends on ____________
the solutions to smaller instances of the same problem.
Which data structure is used to perform recursion?
Stack
Which of the following problems can’t be solved using recursion?
Problems without base case
The case in which the routine calls itself to perform a subtask is called as
recursive case
Recursion is similar to which of the following?
a loop
Which of the following problems can be solved using recursion?
i. Factorial of a number
ii. Nth Fibonacci number
iii. Length of a string
The correspondence between actual and formal parameter is one-to-one basis according to the respective orders.
True
Function prototype provides the basic information about a function which tells the compiler that the function is used correctly or not.
True
A function that can be made to return a single value to the calling program is referred to as void function.
True
The function prototype contains different information than the function header contains.
False
If a variable is declared inside a function, what kind of variable is this?
Local Variable
If the function returns a value then the return_type must be void.
False
The following are problems that often have simple recursive solutions except ________.
display an output
Recursion itself cannot be used as a replacement to iteration or looping
False
The recursive routine always contains a selection statement-either an “if” or a “switch”.
True
Any problem that can be solved recursively cannot also be solved iteratively.
False
How many recursive calls does the following method contain?
2
When a recursive function is executed, the recursive calls are implemented instantly.
False
A ____________________ structure is the main control structure in a recursive routine, and a ____________________ structure is the main control structure in an iterative routine
branching, looping
In for loop, the part that defines how the loop control variable will change each time the loop is repeated.
increment decrement
A continue statement causes execution to skip to ______
the next iteration of the loop
Which looping process is best used when the number of iterations is known
For loop
Which looping process is best used when the number of iterations is known?
For Loop
In do-while, statements in the loop are executed first at least once
True
Where should the prototype be?
before the int main()
What is the value returned as a result when mystery(3) is called?
27
Running out of memory may occur due to ______
Recursive function call
Recursion makes our code shorter and cleaner.
True
A recursive routine performs a task in part by calling itself to perform the subtasks.
True
What is the scope of the variable declared in the user defined function?
only inside the { } block
If we have a function int stop (int n) , can we send it a different variable in the main program? For example, stop (x)
Yes
Only predefined functions can be involved in recursion.
False/ only user defined
All the recursive calls are pushed onto the stack
Yes
How many times is the recursive function called, when the following code is executed?
11
It provides one-way communication of data from the calling program to the function.
Arguments
Which of the following is used to terminate the function prototype?
;
Recursion can be more difficult to debug compared to an equivalent iterative program.
True
What will be the output of the following code?
my_recursive_function(100);
cannot be determined
Any routine that calls itself is recursive.
True
Which of the following statement is correct?
All the parameters of a function can be default parameters.
Where does the return statement returns the execution of the program?
calling function
A recursive program cannot call itself always, or it would never stop at some point, the routine encounters a subtask that it can perform without calling itself.
Base Case