C Program to Find Count of Common Characters in Two Strings
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[1000], ch; int count = 0, i; printf("Enter a string: "); fgets(str, sizeof(str), stdin); printf("Enter a character to find its frequency: "); scanf("%c", &ch); for (i = 0; str[i] != '\0'; ++i) { if (ch == str[i]) ++count; } printf("Frequency of %c = %d", ch, count); getch(); }
Output: