Question: How do I write the code like the exercise is asking using a function? (C Programming language)This is what I got so far: #include #include
How do I write the code like the exercise is asking using a function? (C Programming language)This is what I got so far:
#include #include #define MAX_SIZE 100 // Maximum string size
int main() { char str[MAX_SIZE]; int i; int len; int freq[26];
/* Input string from user */ printf("Enter any string: "); gets(str);
len = strlen(str);
/* Initialize frequency of each character to 0 */ for(i=0; i
/* Find total number of occurrences of each character */ for(i=0; i='a' && str[i]='A' && str[i] /* Print the frequency of all characters in the string */ printf(" Frequency of all characters in the given string: "); for(i=0; i
return 0; }
The exercise is asking this:

Write a C function with prototype void letter_freq(const char wordl, int freq : This function computes the number of appearances of each letter in the string word and stores them in array freq of size 26. The letters are the 26 letters of the Latin alphabet whose ASCII values are in the range 97-122 for the lower case letters, and in the range 65-90 for the uppercase letters. You must account for uppercase and lowercase letter variants, which should be counted together. The counts have to be stored in array freq in alphabetical order of letters, which corresponds to the increasing order of their ASCII values. Specifically, freq[O] should store the count of 'A' and 'a', freq[1] should store the count of B' and b', and so on. This function has also to print the counts indicating each letter and its count on a separate line, as follows The count of 'A' and 'a' is The count of 'B and b'is Write a program to test the function. Hint: If variable x of type char represents a lower case letter, then the corresponding index in the array equals the integer value of x-'a'. Ifx is an upper case letter, then the index in the array equals x- A