#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char string[50];
int count[26],i,j=0,alpha[26],m;
char letter=97;
printf("enter the string\n");
gets(string);
strlwr(string);
for(m=0;m<26;m++)
{
count[m]=0;
i=0;
while(string[i]!=NULL)
{
alpha[m]=letter;
if(alpha[m]==string[i])
{
count[m]++;
}
i++;
}
letter++;
}
printf("\nalphabet\t\t\toccurrence\n");
for(m=0;m<26;m++)
{
if(count[m]!=0)
{
printf("%c\t\t\t\t%d\n",alpha[m],count[m]);
}
}
}
#include<conio.h>
#include<string.h>
void main()
{
char string[50];
int count[26],i,j=0,alpha[26],m;
char letter=97;
printf("enter the string\n");
gets(string);
strlwr(string);
for(m=0;m<26;m++)
{
count[m]=0;
i=0;
while(string[i]!=NULL)
{
alpha[m]=letter;
if(alpha[m]==string[i])
{
count[m]++;
}
i++;
}
letter++;
}
printf("\nalphabet\t\t\toccurrence\n");
for(m=0;m<26;m++)
{
if(count[m]!=0)
{
printf("%c\t\t\t\t%d\n",alpha[m],count[m]);
}
}
}
No comments:
Post a Comment