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
How to get string length of given string in c?
What is %d called in c?
Why clrscr is used in c?
What is spark map function?
What do you mean by invalid pointer arithmetic?
Where are some collections of useful code fragments and examples?
how to make a scientific calculater ?
how should functions be apportioned among source files?
How can you read a directory in a C program?
Can we access array using pointer in c language?
What is a substring in c?
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
What does %p mean?
What is pointer to pointer in c language?
Explain the difference between malloc() and calloc() function?