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
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
Is it possible to execute code even after the program exits the main() function?
Why do some versions of toupper act strangely if given an upper-case letter?
What does typedef struct mean?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
What is unary operator?
Is calloc better than malloc?
Why static is used in c?
What is calloc malloc realloc in c?
What is structure padding in c?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What is the newline escape sequence?
Explain how can I right-justify a string?
write a program to copy the string using switch case?
What is maximum size of array in c?