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
What does typedef struct mean?
Explain that why C is procedural?
How do I send escape sequences to control a terminal or other device?
How can I make it pause before closing the program output window?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
Write a program on swapping (100, 50)
What is the difference between call by value and call by reference in c?
What does c mean in basketball?
Write a program to find the biggest number of three numbers in c?
how to execute a program using if else condition and the output should enter number and the number is odd only...
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
What type is sizeof?
How can I manipulate individual bits?
What is the difference between Printf(..) and sprint(...) ?
Explain the binary height balanced tree?