Search



Thursday, 5 March 2015

frequency of characters in a string

#include <stdio.h>
#include<conio.h>
void main()
{ char c[1000],ch;
int i,count=0;
printf("\n\n program to find frequency of characters in a string");
printf("\n Enter a string ( with spaces accepted ): ");
gets(c);
printf("\n Enter a character to find frequency: ");
scanf("%c",&ch);
for(i=0;c[i]!='\0';i++)
{ if(ch==c[i])
count++;
}
printf("\n\n Frequency of %c = %d", ch, count);
getch();
}

No comments:

Post a Comment

Guys if you think something is wrong or should be edit than please do comment.