Saturday, April 10, 2021

20.40. Write a program that read a line of text and display the frequency of every letter.

#include<stdio.h>
#include<conio.h> 
#include<stdlib.h>
#include<string.h>
void main () 
{
void main ()
char *st;
int i, l, a[26];
st=(char *)malloc(sizeof(char)*100);
clrscr ();
printf("Enter any line of text: ");
gets (st);
l=strlen (st);
for(i=0; i<l; i++)
a[i]=0;
if (*st [i]>='a'&& *st[i]<='z')
a[*(st+i)-97]++;
if (*st [i]>='A'&& *st[i]<='Z')
a[*(st+i)-65]++;
for(i=;i<26;i++)
if(a[i]>0)
printf("\n%c= %d", i+65, a[i]);
getch();
}


No comments:

Post a Comment