65.8k views
1 vote
Void printNum(int num) //Line 1

{ //Line 2
if (n < 0) //Line 3
cout << "Num is negative" << endl; //Line 4
else if (num == 0) //Line 5
cout << "Num is zero" << endl; //Line 6
else //Line 7
{ //Line 8
cout << num << " "; //Line 9
printNum(num – 1); //Line 10
} //Line 11
} //Line 12

Consider the accompanying definition of a recursive function. Which of the statements represent the base case?

(a)-Statements in Lines 3 and 4
(b)-Statements in Lines 5-10
(c)-Statements in Lines 3-6
(d)-Statements in Lines 5 and 6

User Sleafar
by
5.3k points

1 Answer

7 votes

Answer:

(b)-Statements in Lines 5-10

Step-by-step explanation:

Recursion begins when the number is greater than zero.

Otherwise, it is only verified that the number is zero or is a negative number.

User Yurii Kotov
by
4.8k points