character frequency from a string

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

int main()
{
   char string[1000];
   int d = 0, count[26] = {0}, x;

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

   while (string[d] != '\0') {


      if (string[d] >= 'a' && string[d] <= 'z') {
         x = string[d] - 'a';
         count[x]++;
      }

      d++;
   }

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

   return 0;
}

OUTPUT : - 






For Other Programs Visit The WebSite:-   https://www.techapurba.com/

Follow Me On Social Media :-

For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/

Post a Comment

0 Comments