Module 7 Flashcards
A segment that groups a number of program statements to perform specific task
function
Formal parameters are variables used within the function header that receives a copy of the actual argument values.
True
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
From which function the execution of a C++ program starts?
main( ) function
int my_function (double a), what type of data will this functions take in?
double
What is the scope of the global variable declared outside the user defined function and after the preprocessor directive?
Whole prorgram
Which of the following is important in a function?
Both return type and function name
Which data structure is used to perform recursion?
stack
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. This case is called the recursive case.
False
Which of the following statements is true?
Recursion uses more memory compared to iteration
Recursion performs faster while executing the iteration process.
False
In recursion, the condition for which the function will stop calling itself is ____________
base case
Recursion makes our code shorter and cleaner.
True
A function is a self contained block of code with a specific purpose.
True
It consists of data type, name of the function and parameter listing.
function header
Where should the prototype be?
before int main ( )
Where does the execution of the program starts?
main ( ) function
A function that can be made to return a single value to the calling program is referred to as void function.
False
Which of the following statement is correct?
- Only one parameter of a function can be a default parameter.
- No parameter of a function can be default.
- Minimum one parameter of a function must be a default parameter.
- All the parameters of a function can be default parameters.
All the parameters of a function can be default parameters.
The only difference between the header and the prototype is the colon.
False
All the recursive calls are pushed onto the stack
True
Which of the following problems can be solved using recursion?
i. Factorial of a number
ii. Nth Fibonacci number
iii. Length of a string
i,ii,iii
Any problem that can be solved recursively cannot also be solved iteratively.
False
Recursion is a method in which the solution of a problem depends on ____________
Smaller instances of the same problem