Write a program in MIPS assembly that reads a string from a
Write a program in MIPS assembly that reads a string (from a keyboard), stores it in the memory, and computes and prints the frequency of each upper case, each lowercase, and the space character.
For example:
Frequency of characters:
A: 1 times
B: 0 times
C: 0 times
D: 0 times
... etc for uppercase, then lowercase, and spaces.
I tried a psuedocode, but am unable to replicate it in practice.
Solution
Answer- below is the code in C which will solve your problem
int main()
{
char inputString[100];
int index, frequency[256] = {0};
printf(\"Enter a String\ \");
gets(inputString);
for(index=0; inputString[index] != \'\\0\'; index++)
{
frequency[inputString[index]]++;
}
/* Printing each character and frequency of that character in the given string*/
printf(\"\ Character Frequency\ \");
for(index=0; index < 256; index++){
if(frequency[index] != 0){
printf(\"%5c%10d\ \", index, frequency[index]);
}
}
getch();
return 0;
}
