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
List the difference between a While & Do While loops?
Differentiate between new and malloc(), delete and free() ?
Why does notstrcat(string, "!");Work?
What is #include conio h?
What is difference between static and global variable in c?
What are multibyte characters?
What's the best way of making my program efficient?
Is c high or low level?
What are the back slash character constants or escape sequence charactersavailable in c?
Write a program to show the change in position of a cursor using c
What is spaghetti programming?
Can you tell me how to check whether a linked list is circular?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
What is union and structure?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.