Design write and test a program in MIPS using a procedure to

Design, write, and test a program in MIPS using a procedure to produce a sum of products. Similar to program 2, the program should request and reads the number of pairs to input. Iteratively reads each pair and place them into the appropriate array. Call the procedure which calculates the products of each pair and accumulates the result. Upon return from the procedure, the program should output the result.

Solution

#include <stdio.h>
int p[10][3];

int pairaccFun(int p[10][3],int n){
   int i=0;
   for(i=0;i<n;i++){
       p[i][2] = p[i][0] * p[i][1];
   }
}

int main(void) {
   // your code goes here
   int n,i=0;
   printf(\"Number of pairs:\ \");
   scanf(\"%d\",&n);
   for(i=1;i<=n;i++){
       printf(\"Pair %d :\ \",i);
       printf(\"fist value: \");
       scanf(\"%d\",&p[i-1][0]);
       printf(\"second value: \");
       scanf(\"%d\",&p[i-1][1]);
       printf(\"\ \");
   }
   pairaccFun(p,n);
for(i=0;i<n;i++){
       printf(\"%d * %d = %d\ \",p[i][0],p[i][1],p[i][2]);
   }
   return 0;
}

output:

Design, write, and test a program in MIPS using a procedure to produce a sum of products. Similar to program 2, the program should request and reads the number

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site