C program to find frequency of each character in a text
file?

Answer Posted / silky

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

int main()
{
char a[100],s[100];
gets(a);
int i,c[27],j;

for(int i=0;i <=26;i++)
c[i]=0;

for(i=0;i<strlen(a);i++)
{
if(a[i]>='a' && a[i]<='z')
{
c[ a[i] - 'a' ]++;
}
}

for(j=0;j <=26;j++)
{
if(c[j]>0)
{
printf("%c occurs %d times\n ",'a'+j,c[j]);
}
}

}

Is This Answer Correct ?    5 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the uses of a pointer?

689


What is the difference between fread and fwrite function?

644


What does static variable mean in c?

659


Can a file other than a .h file be included with #include?

690


Explain how do you declare an array that will hold more than 64kb of data?

911






Is r written in c?

731


What are the 5 types of inheritance in c ++?

591


What is type qualifiers?

669


What is the maximum no. of arguments that can be given in a command line in C.?

674


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

567


What is a list in c?

627


Why is c faster?

600


Explain 'bit masking'?

661


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1130


What are the advantages of c language?

670