Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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 C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

0 Answers   Subex,


What is the difference between null pointer and wild pointer?

0 Answers  


#include<stdio.h> int main( ) { Int a=300, b, c; if(a>=400) b=300; c=200; printf(“%d%d ”, b, c); return0; }

1 Answers  


Why shouldn’t I start variable names with underscores?

0 Answers  


Is c compiled or interpreted?

0 Answers  






Find Index of least significant bit set in an Integer. ex. int value is say 10001000 results should be 4.

1 Answers  


Why header files are used?

0 Answers  


how to connect oracle in C/C++.

3 Answers   TCS, Wipro,


write a recursive program in'c'to find whether a given five digit number is a palindrome or not

2 Answers  


Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?

7 Answers  


What are the 4 types of functions?

0 Answers  


How to add two numbers with using function?

2 Answers   Miracle Solutions,






Categories