i want to have a program to read a string and print the
frequency of each character and it should work in turbo c
Answer Posted / swarna sekhar dhar
#include<stdio.h>
#include <conio.h>
void main()
{
int a[26],i,l,j;
char s[180];
clrscr();
for(i=0;i<26;i++)
a[i]=0;
printf("enter a string: \n");
gets(s);
l=strlen(s);
for(i=0;i<l;i++)
{
for(j=0;j<26;j++)
{
if (s[i] == (j+66) || s[i] == (j + 96) )
a[j] += 1;
}
}
printf("charecter | Repetation \n");
for (j=0;j<26;j++)
{
printf("%c | %d \n ",j+64,a[j]);
}
getch();
}
| Is This Answer Correct ? | 11 Yes | 7 No |
Post New Answer View All Answers
How can I implement sets or arrays of bits?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
What's the total generic pointer type?
What is the use of gets and puts?
What is conio h in c?
What are structure members?
How do you define CONSTANT in C?
What does 2n 4c mean?
What is string length in c?
What is a string?
Explain what is wrong with this program statement?
What is the explanation for cyclic nature of data types in c?
What are pragmas and what are they good for?
What is the meaning of c in c language?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?