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 is string length in c?
Why header files are used?
What is meant by type casting?
What is the use of sizeof () in c?
write a program to create a sparse matrix using dynamic memory allocation.
What are categories used for in c?
What is data structure in c and its types?
What is data type long in c?
What are the c keywords?
code for replace tabs with equivalent number of blanks
Write a program to check prime number in c programming?
how to capitalise first letter of each word in a given string?
Explain the difference between call by value and call by reference in c language?
When c language was developed?
What are two dimensional arrays alternatively called as?