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
Write a code to remove duplicates in a string.
How do I determine whether a character is numeric, alphabetic, and so on?
Discuss the function of conditional operator, size of operator and comma operator with examples.
Why c language?
What is c language & why it is used?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
Difference between Shallow copy and Deep copy?
Explain how can type-insensitive macros be created?
explain what is a newline escape sequence?
write a progrmm in c language take user interface generate table using for loop?
Explain the advantages of using macro in c language?
what is the role you expect in software industry?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
Do you know what are bitwise shift operators in c programming?
List the difference between a "copy constructor" and a "assignment operator"?