I am trying to convert the following C code to MIPS any help is apprechiated //T
ID: 3550204 • Letter: I
Question
I am trying to convert the following C code to MIPS any help is apprechiated
//The readArray procedure reads integers from user input
void readArray(int array[], int length, int howMany)
{
int num, i = 0;
while (i < length && i < howMany)
{
printf("Enter an integer: ");
//read an integer from a user input and store it in num1
scanf("%d", &num);
array[i] = num;
i++;
}
return;
}
//The increase procedure compare two elements next to each other,
//and if an element is larger than the next element,
//the next element is set to the previous number,
//thus the array content will be in an increasing order.
//Then it prints out the new array content, and returns the new last
element of the array.
int increaseOrder(int array[], int length )
{
int i = 1;
int howMany = 0;
printf("Specify how many numbers should be stored in the array
(at most 8): ");
scanf("%d", &howMany);
readArray(array, length, howMany);
printf("The array content is: ");
printf("%d ", array[0]);
while (i < length && i < howMany)
{
if (array[i-1] > array[i])
{
array[i] = array[i-1];
}
printf("%d ", array[i]);
i++;
}
return array[howMany-1];
}
// The main calls the increaseOrder procedure
void main()
{
int arraysize = 8;
int numbers[arraysize];
int i, ans1, ans2, sum;
ans1 = increaseOrder(numbers, arraysize);;
ans2 = increaseOrder(numbers, arraysize);;
sum = ans1 + ans2;
printf("The sum of two numbers is: %d ", sum);
return;
}
Explanation / Answer
you can covert c code to mips at
http://ctomips.com/ctomips_payment/jsp/demoupload.jsp
I always use this link for such purpose...
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.