Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

c program to find the frequency of characters in a string

#include <stdio.h>
int main() {
    char str[1000], ch;
    int count = 0;

    printf("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    printf("Enter a character to find its frequency: ");
    scanf("%c", &ch);

    for (int i = 0; str[i] != ''; ++i) {
        if (ch == str[i])
            ++count;
    }

    printf("Frequency of %c = %d", ch, count);
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: arrays in c 
C :: typedef vs #define 
C :: delete string function in c 
C :: c sizeof operator 
C :: printing out an array in c from user input 
C :: enregistrement en c 
C :: c bubble sort 
C :: variables in c 
C :: convert string to int c 
C :: actionbar content color in android 
C :: class in oops 
C :: c print characters 
C :: pandoc set margins pdf 
C :: implement crc using c language 
C :: c program to find minimum of 5 numbers using conditional operator in c 
C :: c list 
C :: Relational Operator in C language 
C :: Find the how many bits is turned on in a numebr 
C :: functions in c programming 
C :: C Syntax of goto Statement 
C :: marquee html code with right 
C :: promt user input C 
C :: String to Integer (atoi) 
C :: anthracnose pronounce 
C :: C Assigning addresses to Pointers 
C :: first come first serve 
C :: c math.h sqrt 
C :: transform yt video into background overlay 
C :: passing an array to a function 
C :: c# Regex similar wor 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =