Q3. The attached C# program (Recursion_Demo.cs) demonstrates the concept of recursion. The program inputs the value of n from the user and then the recursive RDemo method prints the following sequence: n (n-1) (n-2) … 1 1 2 3 … n Execute the program and check it out for yourself. You will write a MIPS program which MUST use a non-leaf procedure to implement this recursive method. Iterative implementation of the program will NOT be accepted. Your program will define a non-leaf procedure RDemo which will be called recursively for n>=1. RDemo will return when n<1. Your program will print the user prompt and take n as an input in the main program. The output on the screen must be just similar to the C# program – there will be space between the integers. Obviously, your MIPS program will not implement the concept of class
using System;
public static class LearnRecursion
{
public static void Main()
{
int n;
Console.Write(“Enter an integer: “);
n = Convert.ToInt32(Console.ReadLine());
RDemo(n);
}
public static void RDemo(int n)
{
if (n < 1)
{
return;
}
else
{
Console.Write(“{0} “, n);
RDemo(n – 1);
Console.Write(“{0} “, n);
return;
}
}
}