Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

I want to have a program to read a string and print the frequency of each character and it should work in turbo c 
Our desired program is that,

#include<stdio.h>
#include <conio.h>
void main()
{
   int i[26],m,l,n;
   char str[180];
   clrscr();
   for(m=0;m<26;m++)
   i[m]=0;
   printf("Enter a string: 
");
   gets(str);
   l=strlen(str);
   for(m=0;m<l;m++)
   {
      for(n=0;n<26;n++)
      {
         if(str[m]==(n+66) || str[m]==(n + 96))
	 a[n] += 1;
      }
   }
   printf("charecter | Repetation 
");
   for (n=0;n<26;n++)
   {
      printf("%c       |   %d   
 ",n+64,a[n]);
   }
   getch();
}