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
What are the uses of a pointer?
What is the difference between fread and fwrite function?
What does static variable mean in c?
Can a file other than a .h file be included with #include?
Explain how do you declare an array that will hold more than 64kb of data?
Is r written in c?
What are the 5 types of inheritance in c ++?
What is type qualifiers?
What is the maximum no. of arguments that can be given in a command line in C.?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What is a list in c?
Why is c faster?
Explain 'bit masking'?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
What are the advantages of c language?