Question: Convert the C code into MIPS Assembly language, the code is about testing a number is prime or not prime, here's the code: #include int

Convert the C code into MIPS Assembly language, the code is about testing a number is prime or not prime, here's the code:
#include
int prime(int n){
if (n ==1){
return 0;
}
for (int i =2; i*i <= n; i++){
if (n%i ==0){
return 0;
}
}
return 1;
}
int main(){
int n;
printf("Please input a number: ");
scanf("%d", &n);
if (prime(n)){
printf("It's a prime
");
} else {
printf("It's not a prime
");
}
return 0;
}
Please run it on ubuntu(linux) and attached the screenshot of the output.

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!