C Program to Count Frequency of Characters
Advertisements
Find Frequency of Characters Program in C
Frequency of character in any string means how many times a particular character is present in any string.
C Program to Find Frequency of Characters
#include<stdio.h> #include<conio.h> void main() { int i,count=0; char ch[20],c; clrscr(); printf("Enter Any String: "); gets(ch); printf("Enter any Character form string: "); scanf("%c",&c); for(i=0;ch[i]!='\0';i++) { if(ch[i]==c) count++; } if(count==0) { printf("Given character not found"); } else { printf("Repetition of %c is %d times",c,count); } getch(); }
Output
Enter any String: india Enter any Character form string Repetition of i is 2 times
Google Advertisment