#include < stdio.h >
#include<conio.h>
#include < string.h >
#include < string.h >
int main()
{
char string[100];
int c = 0, count[26] = {0};
{
char string[100];
int c = 0, count[26] = {0};
printf("Enter a string\n");
gets(string);
gets(string);
while ( string[c] != '\0' )
{
/* Considering characters from 'a' to 'z' only */
{
/* Considering characters from 'a' to 'z' only */
if ( string[c] >= 'a' && string[c] count[string[c]-'a']++;
c++;
}
}
for ( c = 0 ; c < 26 ; c++ )
{
if( count[c] != 0 )
printf("%c occurs %d times in the entered string.\n",c+'a',count[c]);
}
{
if( count[c] != 0 )
printf("%c occurs %d times in the entered string.\n",c+'a',count[c]);
}
getch();
}
No comments:
Post a Comment