Module 7 Flashcards

1
Q

A segment that groups a number of program statements to perform specific task

A

function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Formal parameters are variables used within the function header that receives a copy of the actual argument values.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If we have a function int stop (int n) , can we send it a different variable in the main program? For example, stop (x)

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

From which function the execution of a C++ program starts?

A

main( ) function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

int my_function (double a), what type of data will this functions take in?

A

double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the scope of the global variable declared outside the user defined function and after the preprocessor directive?

A

Whole prorgram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following is important in a function?

A

Both return type and function name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which data structure is used to perform recursion?

A

stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following statements is true?

A

Recursion uses more memory compared to iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Recursion performs faster while executing the iteration process.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In recursion, the condition for which the function will stop calling itself is ____________

A

base case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Recursion makes our code shorter and cleaner.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A function is a self contained block of code with a specific purpose.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

It consists of data type, name of the function and parameter listing.

A

function header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where should the prototype be?

A

before int main ( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Where does the execution of the program starts?

A

main ( ) function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

A function that can be made to return a single value to the calling program is referred to as void function.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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.
A

All the parameters of a function can be default parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

The only difference between the header and the prototype is the colon.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

All the recursive calls are pushed onto the stack

22
Q

Which of the following problems can be solved using recursion?

i. Factorial of a number
ii. Nth Fibonacci number
iii. Length of a string

23
Q

Any problem that can be solved recursively cannot also be solved iteratively.

24
Q

Recursion is a method in which the solution of a problem depends on ____________

A

Smaller instances of the same problem

25
Where does the return statement returns the execution of the program?
calling function
26
If a variable is declared inside a function, what kind of variable is this?
local variable
27
What will happen while using pass by reference? - The function declaration should contain ampersand (& in its type declaration) - The values of those variables are passed to the function so that it can manipulate them - The location of variable in memory is passed to the function so that it can use the same memory area for its processing
The location of variable in memory is passed to the function so that it can use the same memory area for its processing
28
It provides one-way communication of data from the calling program to the function.
pass by value
29
Which of the following is the default return value of functions in C++?
int
30
The number of actual arguments must be _________ as the number of formal parameters.
equal
31
The case in which the routine calls itself to perform a subtask, is called as base case.
False
32
When a recursive function is executed, the recursive calls are implemented instantly.
False
33
Any routine that calls itself is recursive.
True
34
The recursive routine always contains a selection statement-either an "if" or a "switch".
True
35
Recursion itself cannot be used as a replacement to iteration or looping
False
36
Recursion is similar to which of the following? - loop - nested ifs - if-else - switch_case
loop
37
Which of the following problems can’t be solved using recursion? - Nth fibonacci number - Problems without base case - Length of a string - Factorial of a number
Problems without base case
38
If the function returns a value then the return_type must be void.
False
39
Here is a function, double numbers (int x), what data type will this function return?
double
40
By default how the value are passed in C++?
call by value
41
Which of the following is used to terminate the function prototype?
;
42
The following are problems that often have simple recursive solutions except ________.
display an output
43
Recursion is required in problems concerning advanced algorithms such as Graph and Tree Traversal.
True
44
Which is NOT an essential feature of a proper recursive function?
Not permitted to do any I/O
45
Only predefined functions can be involved in recursion.
False
46
What is the scope of the variable declared in the user defined function?
only inside the { } block
47
Which is more effective while calling the functions?
call by reference
48
The program that calls a function is often referred to as the calling program.
True
49
If a variable is declared outside a function and can be used by other functions, what kind of variable is this?
global variable
50