Question: I am supposed to translate this C code into MIPS assembly language. My current code I believe is close and looping correctly, however, I think

I am supposed to translate this C code into MIPS assembly language. My current code I believe is close and looping correctly, however, I think I am accessing the arrays wrong or something.

void main() { int numbers[11] = {-27, 3, 46, -7, 11, 24, -5, 14, -18, 12, 35}; int index, num2; int j; printf("Enter an integer: "); //read an integer from a user input and store it in index scanf("%d", &index); printf("Enter another integer: "); //read an integer from a user input and store it in num2 scanf("%d", &num2); for (j = 0; j < 11 && j <= index; j = j+1) { if (numbers[j] % num2 == 0) { numbers[j] = numbers[j]*num2; } } printf("Result Array Content: "); for (j = 0; j < 11; j = j+1) { printf("%d ", numbers[j]); } return; }

The following is a sample output (user input is in bold):

Enter an integer: 5 Enter another integer: 3 Result Array Content: -81 9 46 -7 11 72 -5 14 -18 12 35

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!