In this sample C program asks user to enter a string and a character and checks how many times the character is repeated in the string.
char str, ch;
int i, frequency = 0;
printf("Enter a string: ");
printf("Enter a character to find the frequency: ");
for(i = 0; str[i] != '\0'; ++i)
if(ch == str[i])
printf("Frequency of %c = %d", ch, frequency);
Enter a string: This website is awesome.
Enter a character to find the frequency: e
Frequency of e = 4