Tuesday, September 18, 2012

Code#87:c program to find frequency of characters in a string

| |
#include<stdio.h>
#include<string.h>

main()
{
   char string[100], ch;
   int c = 0, count[26] = {0};

   printf("Enter a string\n");
   gets(string);

   while ( string[c] != '\0' )
   {
      /* Considering characters from 'a' to 'z' only */

      if ( string[c] >= 'a' && string[c] <= 'z' )
         count[string[c]-'a']++;

      c++;
   }

   for ( c = 0 ; c < 26 ; c++ )
   {
      if( count[c] != 0 )
         printf("%c occurs %d times in the entered string.\n",c+'a',count[c]);
   }

   return 0;
}


characters frequency in string

1 comments:

AOL is one of the reliable email services that is used by many users. It comes with great features. However, while using the AOL web-based email service, many users confront various issues. These issues become the hurdle between the effective working of the AOL Customer service number uk email. A user can dial our AOL Customer support number and get in touch with us.

Post a Comment

Powered by Blogger.