162. C Program to find Occurrences of each character from the Given String.
How does this program work?
- This Program is used to find the occurances of each character from the given string.
Here is the code
#include <stdio.h>
int main()
{
char sk[100];
int i,j,k,count = 0,n;
printf("Enter Your string to count each : ");
gets(sk);
for(j=0;sk[j];j++);
n = j;
printf("\nCount of character in string:\n");
for(i=0;i< n;i++)
{
count = 1;
if(sk[i])
{
for(j=i+1;j< n;j++)
{
if(sk[i]==sk[j])
{
count++;
sk[j] = '\0';
}
}
printf(" '%c' = %d ",sk[i],count);
}
}
return 0;
}