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 / rahul
#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+65) || s[i] == (j + 97) )
a[j] += 1;
}
}
printf("charecter | Repetation \n");
for (j=0;j<26;j++)
{
printf("%c | %d \n ",j+65,a[j]);
}
getch();
}
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
Are the outer parentheses in return statements really optional?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
What is time complexity c?
Explain the difference between the local variable and global variable in c?
Explain what is the benefit of using const for declaring constants?
Explain how can I open a file so that other programs can update it at the same time?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
What is the usage of the pointer in c?
Dont ansi function prototypes render lint obsolete?
Is r written in c?
Give differences between - new and malloc() , delete and free() ?
What is c language and why we use it?
What is %lu in c?
What functions are used in dynamic memory allocation in c?
What is the use of header files?