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
Define macros.
What is wrong in this statement? scanf(ā%dā,whatnumber);
what is the syallabus of computer science students in group- 1?
What is the purpose of realloc()?
What are reserved words?
Is there a built-in function in C that can be used for sorting data?
#include
What does c mean before a date?
What are pointers in C? Give an example where to illustrate their significance.
Write a program to check armstrong number in c?
using only #include
What is pragma c?
How can I open files mentioned on the command line, and parse option flags?
What is the size of structure in c?
What are external variables in c?