Write a program to input a string and print frequency of each character of the string.
Answers
Answered by
7
C
#include <stdio.h>
#include <string.h>
int main()
{
char string[] = "picture perfect";
int i, j, length = strlen(string);
int freq[length];
for(i = 0; i < strlen(string); i++) {
Answered by
0
Answer:
In this program, we need to find the frequency of each character present in the word.
Explanation:
To accomplish this task, we will maintain an array called freq with same size of the length of the string. Freq will be used to maintain the count of each character present in the string. Now, iterate through the string to compare each character with rest of the string. Increment the count of corresponding element in freq. Finally, iterate through freq to display the frequencies of characters.
For example: Frequency of p in above string is 2
Similar questions