Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert the following program into MIPS MARS #include #include void fun(int *A, int i, int j){ // check division by 0 if(A[j]==0){ printf(Illegal operation, division

Convert the following program into MIPS MARS

#include #include void fun(int *A, int i, int j){ // check division by 0 if(A[j]==0){ printf("Illegal operation, division by 0. "); } else{ int quotient = A[i]/A[j]; int remainder = A[i]%A[j]; printf("%d/%d:Quotient is %d, remainder is %d ", A[i], A[j], quotient, remainder); } } int main(){ // allocate an array of integer type with size 8 on heap int *A = (int*) malloc(8 * sizeof(int)); //pointer A holds the base address of this array int i = 0; // to count how many numbers has been entered int n; // to temporary hold user's input // ask user's input, while(i<8){ printf("Enter a natural number: "); scanf ("%d",&n); // scan the input and store it in variable n A[i]=n; i++; } // use to hold user's input int index1; int index2; printf("Enter an index: "); scanf ("%d",&index1); printf("Enter an index: "); scanf ("%d",&index2); // check boundary if(index1 < 0 || index1 > 7 || index2 < 0 || index2 > 7){ printf("Invalid input. Out of boundary. "); } else{ fun(A, index1, index2); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions