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


Please Help Members By Posting Answers For Below Questions

Define macros.

786


What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

730


what is the syallabus of computer science students in group- 1?

1845


What is the purpose of realloc()?

672


What are reserved words?

656






Is there a built-in function in C that can be used for sorting data?

745


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5210


What does c mean before a date?

592


What are pointers in C? Give an example where to illustrate their significance.

752


Write a program to check armstrong number in c?

635


using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1315


What is pragma c?

615


How can I open files mentioned on the command line, and parse option flags?

596


What is the size of structure in c?

703


What are external variables in c?

548