Summative #7 Flashcards

1
Q

What are the mandatory parts of a function declaration?

A

return type and function name

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

A function that can be made to return a single value to the calling program.

A

void

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

The program that calls a function is often referred to as the calling program.

A

True

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

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

A

the solutions to smaller instances of the same problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
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
6
Q

Which of the following problems can’t be solved using recursion?

A

Problems without base case

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

The case in which the routine calls itself to perform a subtask is called as

A

recursive case

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

Recursion is similar to which of the following?

A

a loop

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

Which of the following problems can be solved using recursion?

A

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

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

The correspondence between actual and formal parameter is one-to-one basis according to the respective orders.

A

True

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

Function prototype provides the basic information about a function which tells the compiler that the function is used correctly or not.

A

True

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

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

A

True

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

The function prototype contains different information than the function header contains.

A

False

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

If a variable is declared inside a function, what kind of variable is this?

A

Local Variable

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

If the function returns a value then the return_type must be void.

A

False

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

The following are problems that often have simple recursive solutions except ________.

A

display an output

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

Recursion itself cannot be used as a replacement to iteration or looping

A

False

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

The recursive routine always contains a selection statement-either an “if” or a “switch”.

A

True

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

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

A

False

20
Q

How many recursive calls does the following method contain?

A

2

21
Q

When a recursive function is executed, the recursive calls are implemented instantly.

A

False

22
Q

A ____________________ structure is the main control structure in a recursive routine, and a ____________________ structure is the main control structure in an iterative routine

A

branching, looping

23
Q

In for loop, the part that defines how the loop control variable will change each time the loop is repeated.

A

increment decrement

24
Q

A continue statement causes execution to skip to ______

A

the next iteration of the loop

25
Q

Which looping process is best used when the number of iterations is known

A

For loop

26
Q

Which looping process is best used when the number of iterations is known?

A

For Loop

27
Q

In do-while, statements in the loop are executed first at least once

A

True

28
Q

Where should the prototype be?

A

before the int main()

29
Q

What is the value returned as a result when mystery(3) is called?

A

27

30
Q

Running out of memory may occur due to ______

A

Recursive function call

31
Q

Recursion makes our code shorter and cleaner.

A

True

32
Q

A recursive routine performs a task in part by calling itself to perform the subtasks.

A

True

33
Q

What is the scope of the variable declared in the user defined function?

A

only inside the { } block

34
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

35
Q

Only predefined functions can be involved in recursion.

A

False/ only user defined

36
Q

All the recursive calls are pushed onto the stack

A

Yes

37
Q

How many times is the recursive function called, when the following code is executed?

A

11

38
Q

It provides one-way communication of data from the calling program to the function.

A

Arguments

39
Q

Which of the following is used to terminate the function prototype?

A

;

40
Q

Recursion can be more difficult to debug compared to an equivalent iterative program.

A

True

41
Q

What will be the output of the following code?
my_recursive_function(100);

A

cannot be determined

42
Q

Any routine that calls itself is recursive.

A

True

43
Q

Which of the following statement is correct?

A

All the parameters of a function can be default parameters.

44
Q

Where does the return statement returns the execution of the program?

A

calling function

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

A

Base Case