C Program to Count Frequency of Characters

Advertisements

Prev Tutorial Next Tutorial

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

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements