implement the count letter function so that it return how many occurance c++ code example
Example 1: count a character in a string c++
count(str.begin(), str.end(), 'e')
Example 2: c program to the count the number of times each character appears
int main() {
char str[1000], ch;
int count = 0;
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
printf("Enter a character to find its frequency: ");
scanf("%c", &ch);
for (int i = 0; str[i] != '\0'; ++i) {
if (ch == str[i])
++count;
}
printf("Frequency of %c = %d", ch, count);
return 0;
}