Question: This problem is to be solved in MIPS assembly language Write a main program that prompts the user to enter a decimal integer between 1

This problem is to be solved in MIPS assembly language

Write a main program that prompts the user to enter a decimal integer between 1 and 12, inclusive. The main program should call a recursive function (recurse) and pass the integer as an argument to the function.

The recursive function accepts a single positive integer as an input argument and is defined as:

recurse(n) = 1 if n=0

recurse(n) = n * recurse(n-1) + 1 if n >0

In addition, the recursive function should print an entry message each time that the function is entered and an exit message upon each return from the recursive function.

The entry message should consist of 2n spaces (where n is the function argument), followed by Recursing , followed by the decimal value of the argument n.

The exit message should consist of 2n spaces, followed by Returning , followed by the decimal value of the returned result.

The figures below show output for inputs 0 and 7, respectively.

Enter an integer between 0 and 12: 0

Recursing 0

Returning 1

Goodbye

Enter an integer between 0 and 12: 7

Recursing 7

Recursing 6

Recursing 5

Recursing 4

Recursing 3

Recursing 2

Recursing 1

Recursing 0

Returning 1

Returning 2

Returning 5

Returning 16

Returning 65

Returning 326

Returning 1957

Returning 13700

Goodbye

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!