Question
Please help me in this, Write a simple MIPS program that does the following (there is C++ sample code below to explain the logic): Create
-
Please help me in this, Write a simple MIPS program that does the following (there is C++ sample code below to explain the logic): Create an array of 21 INTEGERS, you can put whatever you want in it, but they shouldnt be sorted. Without using recursion:
- Create a procedure to find the largest called Findlargest
- Create a procedure to find the smallest called Findsmallest.
- Create procedure called range, which is the difference between largest and smallest (range should call findLargest and findSmallest)
- Here is the sample of C++ Code
-
#include "pch.h" //Theres no equivalent to this in MIPS so ignore it
#include
//theres no equivalent to this either. int theArray[] = { 5, 7, 1, 4, 9, 11, 15, 0, -1 };
int findLargest()
{
int temp = theArray[0];
for (int i = 0; i < 10; i++)
if (temp < theArray[i])
temp = theArray[i];
return temp;
}
int findSmallest()
{
int temp = theArray[0];
for (int i = 0; i < 10; i++)
if (temp > theArray[i])
temp = theArray[i];
return temp;
}
int findRange()
{
return findLargest() - findSmallest();
}
int main()
{ std::cout << findLargest() << std::endl;
std::cout << findSmallest() << std::endl;
std::cout << findRange() << std::endl;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started