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
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 |
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 |
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
What is this infamous null pointer, anyway?
How can I list all of the predefined identifiers?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
How do I round numbers?
How. To pass the entrance test
enum { SUNDAY, MONDAY, TUESDAY, }day; main() { day =20; printf("%d",); getch(); } what will be the output of the above program
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
HOW TO FIND OUT THE RREVERS OF A GIVEN DIGIT NUMBER IF IT IS INPUT THROUGH THE KEYBORD BY USING C LANGUAGE
What does d mean?
What are header files in c programming?