Write a complete MIPS program to toggle the case of all alphabetic characters in
ID: 3882643 • Letter: W
Question
Write a complete MIPS program to toggle the case of all alphabetic characters in a C-string held in RAM in your program. Declare the string with a reasonable value (a 5 or 6 word sentence with spaces and punctuation) and print it before and after toggling the case of all alphabetic characters in the string. Do not add notes to the top of the program, but you may comment individual lines. The upper-case characters are 32 less than their corresponding lower-case characters. (less than 40 lines of code)
Explanation / Answer
#include <stdio.h>
int main()
{
char str[100];
int counter;
printf("Enter a string: ");
gets(str);
for(counter=0;str[counter]!=NULL;counter++)
{
if(str[counter]>='A' && str[counter]<='Z')
str[counter]=str[counter]+32; //convert into lower case
else if(str[counter]>='a' && str[counter]<='z')
str[counter]=str[counter]-32; //convert into upper case
}
printf("String after toggle each characters: %s",str);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.