Bxbigboy7845 Bxbigboy7845
  • 19-07-2019
  • Computers and Technology
contestada

How many base cases are in the functionabove?

a. 0

b. 1

c. 2

d. 3

int func2(int m, int n) {

if (n == 0)

return 0;

else

return m + func2(m, n-1);

}

Respuesta :

ExieFansler ExieFansler
  • 23-07-2019

Answer:

The answer is (b). 1.

Explanation:

In the code there is only 1 base case .

the base case is as following:-

if(n==0)

return 0;

this is the base case.

Base case is the most important statement in the function that uses recursion because without base case the recursion calls will keep on going and we will get a run time error.

Answer Link

Otras preguntas

if a+b+c=0 for a,b,c then prove a²/bc+b²/ca+c²/ab=3.
What makes a pear or fig gritty?
What is the answer to 5x-7y=14
the ill effects of building a dam on a major river.
What makes a pear or fig gritty?
1.What is the probability of choosing a face card from a deck of 52 cards (face cards are jacks, queens, and kings)? What is the probability of the 2nd card bei
Two glasses together contain 280 mLof water. The first glass contains 80 ml more than the second glass. How much water does the first glass contain?
compare the invention of the atlatl withthe invention of the bow and arrow, cannon, machine gun, and combat aircraft. discuss impacts of these in their times.
spread of democracy in last 15 years
A fair coin is tossed 5 times. What is the probability of obtaining exactly 3 heads.