Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started