Question: Write a MIPS program to do the followings: read a string from a keyboard (25%) use a character array count the number of characters in
Write a MIPS program to do the followings:
read a string from a keyboard (25%)
use a character array
count the number of characters in the string (25%)
use loop
reverse the string and print the reversed string(50%)
use loop and a temp character array for reversing
main() { char input[1024];
char temp[1024];
int i, str_length = 0;
scanf("%s", input); while( input[i] != '\0' ){ i++;
}
str_length = i;
for(i=0; str_length >= 1; str_length--){ temp[i] = input[str_length - 1];
i++;
}
temp[i] = '\0';
printf("Original string is %s ", input); printf("Reversed string is %s", temp); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
