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


Please Help Members By Posting Answers For Below Questions

What does typedef struct mean?

644


Explain that why C is procedural?

646


How do I send escape sequences to control a terminal or other device?

600


How can I make it pause before closing the program output window?

564


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

760






Write a program on swapping (100, 50)

630


What is the difference between call by value and call by reference in c?

610


What does c mean in basketball?

552


Write a program to find the biggest number of three numbers in c?

579


how to execute a program using if else condition and the output should enter number and the number is odd only...

1645


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

633


What type is sizeof?

573


How can I manipulate individual bits?

594


What is the difference between Printf(..) and sprint(...) ?

773


Explain the binary height balanced tree?

712