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
Can variables be declared anywhere in c?
What is structure and union in c?
What type is sizeof?
What is the use of structure padding in c?
Explain what is page thrashing?
How can you restore a redirected standard stream?
#include
Differentiate between the = symbol and == symbol?
Why is C language being considered a middle level language?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
Is main is a keyword in c?
What is strcmp in c?
Do character constants represent numerical values?
console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above
When can you use a pointer with a function?