Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C language!!!! Write a program that will prompt the user for a string. Read t

ID: 3937481 • Letter: I

Question

In C language!!!!

Write a program that will prompt the user for a string. Read the string using gets(). Convert the string to all capitals using your my_strupper function from the earlier problem. Next, write a loop to cycle thru each character of the string, and count the occurance of each letter. Store these values in int freqs[26]; Hint: In the loop, convert each character in the string into a zero-based index by subtracting 'A', and use this as an index into freqs. Lastly, use freqs and a loop to output a table of these letters and their frequencies, ommiting those with a frequency of zero. Do not use any string processing library functions. Hint:

// hmmm, what does this do??

freqs[str[i] - 'A']++;

// hmmm, and this??

printf("%c %d ", i + 'A', freqs[i]);

Sample Output:

Please enter a string: Foobar

A 1

B 1

F 1

O 2

R 1

Press any key to continue...

Explanation / Answer

#include #include int main() { char s[]; int i, l; int freq[26]; /* Reads a string from user */ printf("Enter a string: "); gets(s); l = strlen(s); /* Initializes frequency of each character to 0 */ for(i=0; i