i want to have a program to read a string and print the
frequency of each character and it should work in turbo c

Answers were Sorted based on User's Feedback



i want to have a program to read a string and print the frequency of each character and it should..

Answer / 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

i want to have a program to read a string and print the frequency of each character and it should..

Answer / 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

i want to have a program to read a string and print the frequency of each character and it should..

Answer / shashi

33 45

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More C Interview Questions

Is null a keyword in c?

0 Answers  


what type of questions arrive in interview over c programming?

0 Answers  


What is the use of #define preprocessor in c?

0 Answers  


#include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain &#1567;&#1567;&#1567;

4 Answers  


What is typedef struct in c?

0 Answers  






Explain heap and queue.

0 Answers   Aricent,


please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics

0 Answers  


What happens if header file is included twice?

0 Answers  


How can I find out if there are characters available for reading?

0 Answers  


Explain void pointer?

0 Answers  


write a C code To reverse a linked list

2 Answers   Motorola, Wipro,


What does the error 'Null Pointer Assignment' mean and what causes this error?

0 Answers   TISL,


Categories