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 4 data types?
Why malloc is faster than calloc?
why programs in c are running with out #include
What are the different types of linkage exist in c?
How many types of errors are there in c language? Explain
What are the differences between new and malloc in C?
the question is that what you have been doing all these periods (one year gap)
Explain what is #line used for?
How many header files are in c?
Explain what is dynamic data structure?
What is methods in c?
What is string constants?
What are the different types of endless loops?
how many key words availabel in c a) 28 b) 31 c) 32
Explain what does the format %10.2 mean when included in a printf statement?