#include <stdio.h>
#include <string.h>
int main() {
char sentence[100];
char ch;
int count = 0;
printf("Enter a sentence: ");
fgets(sentence, sizeof(sentence), stdin);
printf("Enter the character to count: ");
scanf(" %c", &ch);
for (int i = 0; sentence[i] != '\0'; i++) {
if (sentence[i] == ch) {
count++;
}
}
printf("Frequency of '%c' in the sentence: %d\n", ch, count);
return 0;
}
Comments
Post a Comment