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

write a progrmm in c language take user interface generate table using for loop?

0 Answers  


what is void pointer?

1 Answers   Wipro,


What are the advantages of using linked list for tree construction?

0 Answers  


Explain what is the advantage of a random access file?

0 Answers  


what is the difference between const volatile int i & volatile const int j;

2 Answers   HCL,






Is struct oop?

0 Answers  


What is clrscr ()?

0 Answers  


when i declare as: void main() { clrscr(); int a=10; printf("%d",a) } my problem that why generate a error in above programs. please tell me answer seriously .

4 Answers  


How to add two numbers without using semicolon at runtime

2 Answers  


Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

0 Answers  


a=(1,2,3); b=1,2,3; c=1,(2,3); d=(1,2),3; what's the value of 'a','b','c','d'

2 Answers  


write a function for strtok()??

2 Answers   Verifone,


Categories