Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c program to find the frequency of all characters in a string

#include <stdio.h>
#include <string.h>
 
int main()
{
    char s[1000];  
    int  i,j,k,count=0,n;
 
    printf("Enter  the string : ");
    gets(s);
     
    for(j=0;s[j];j++);
	 n=j; 
    
	printf(" frequency count character in string:
");
 
    for(i=0;i<n;i++)  
    {
     	count=1;
    	if(s[i])
    	{
		
 		  for(j=i+1;j<n;j++)  
	      {   
	    	
	        if(s[i]==s[j])
    	    {
                 count++;
                 s[j]='';
	     	}
	      }  
	      printf(" '%c' = %d 
",s[i],count);
 
	       
	   
       }
	   
	   
 	} 
 	 
     
    return 0;
}
Source by javatutoring.com #
 
PREVIOUS NEXT
Tagged: #program #find #frequency #characters #string
ADD COMMENT
Topic
Name
7+3 =