Complete the code to declare an array to store frequency of all ASCII characters.
int freq[[1]] = {0};
The ASCII table has 256 characters, so we need an array of size 256 to store frequency counts.
Complete the code to increment the frequency count of the current character in the string.
freq[(unsigned char)[1]]++;We use str[i] to access the current character in the string and increment its frequency.
Fix the error in the loop condition to iterate over the string until the end.
for (int i = 0; str[i] [1] '\0'; i++) {
The loop should continue while the current character is not the null terminator '\0'.
Fill both blanks to print characters and their frequencies only if frequency is greater than zero.
for (int i = 0; i < [1]; i++) { if (freq[i] [2] 0) { printf("%c: %d\n", i, freq[i]); } }
We loop through all 256 ASCII characters and print only those with frequency greater than zero.
Fill all three blanks to create a function that counts character frequency and prints the result.
void countFrequency(const char *[1]) { int freq[[2]] = {0}; for (int i = 0; [3][i] != '\0'; i++) { freq[(unsigned char)[3][i]]++; } for (int i = 0; i < 256; i++) { if (freq[i] > 0) { printf("%c: %d\n", i, freq[i]); } } }
The function takes a string named 'str', uses an array of size 256, and loops over 'str' to count frequencies.
