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
Why is c called "mother" language?
Can we change the value of constant variable in c?
What is memory leak in c?
what is the different bitween abap and abap-hr?
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
hi any body pls give me company name interview conduct "c" language only
What are the benefits of c language?
How can I remove the trailing spaces from a string?
How can you restore a redirected standard stream?
Is it acceptable to declare/define a variable in a c header?
What is wrong with this initialization?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
using only #include
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?