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
what is use of malloc and calloc?
Tell me can the size of an array be declared at runtime?
What is the difference between test design and test case design?
Explain how do you view the path?
How #define works?
What is pointer and structure in c?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Differentiate fundamental data types and derived data types in C.
What are lookup tables in c?
application attempts to perform an operation?
Sir i need notes for structure,functions,pointers in c language can you help me please
What are the features of c languages?
What does void main () mean?
What is structure packing in c?
What is pass by value in c?