c please AL-3-7dvi s/AL-2-D%20( 1 ).PDF ww Lc. Course Materials HC Get 2017 heal
ID: 3715691 • Letter: C
Question
c please
AL-3-7dvi s/AL-2-D%20( 1 ).PDF ww Lc. Course Materials HC Get 2017 health cov Member Online Serv 1/2 1. Write three MIPS Assembly programs to implement the following math pressions (use the "loop approach": see lecture notes): (b) 2D: ? ?[j + (2 + 11 (c) 3D: ? ? ?[k + j + (2' + 11 Place the result, of each mathematical expression, in the console of MARS . In the report also include the appropriate screeushots. 2. Propose and solve your own "unique" mathematical expression. . In the report also include the appropriate sereenshot. 2. Pxopose aud wlve unieExplanation / Answer
#include <stdio.h>
#include<math.h>
int oneD(){
int i;
int sum=0;
for(i=1;i<=4;i++)
{
sum+=pow(2,i)+1;
}
return sum;
}
int twoD(){
int i,j;
int sum=0;
for(j=1;j<=3;j++){
for(i=1;i<=3;i++)
{
sum+=pow(2,i)+1+j;
}
}
return sum;
}
int threeD(){
int i,j,k;
int sum=0;
for(k=1;k<=2;k++){
for(j=1;j<=2;j++){
for(i=1;i<=2;i++)
{
sum+=pow(2,i)+1+j+k;
}
}
}
return sum;
}
int main() {
//code
printf("1D = %d ",oneD());
printf("2D =%d ",twoD());
printf("3D = %d ",threeD());
return 0;
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.