//Count
occurrences of alphabets in the given paragraph.
//This program
will count only A to Z alphabets.
#include<stdio.h>
int main(){
int i, counter[26]={}, ch;
char str[100];
puts("Enter your paragraph:");
gets(str);
for(i=0; i<strlen(str); i++)
{
ch=str[i];
counter[ch-65]++;
}
printf("Character and it's frequency
is as under:\n");
for(i=0; i<26; i++)
{
if(counter[i]!=0)
printf("%c = %d \n",
i+65,counter[i]);
}
return 0;
}
|
Output of the program:
Enter your paragraph:
HELLO STUDENT HOW ARE YOU
Character and it's frequency is as under:
A = 1
D = 1
E = 3
H = 2
L = 2
N = 1
O = 3
R = 1
S = 1
T = 2
U = 2
W = 1
Y = 1
No comments:
Post a Comment