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 |
write c program without semicolon
11 Answers MindTech, TCS, Wipro,
how to multiply two number taking input as a string (considering sum and carry )
What is the meaning of c in c language?
What is the difference between c &c++?
How can I find the modification date of a file?
what is the different between data structure and data type?
How is null defined in c?
What is the difference between typedef and #define?
What is pointer to pointer in c with example?
What are the different types of pointers used in c language?
how to execute a program using if else condition and the output should enter number and the number is odd only...
#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }