Create a integer array of the length 26 and fill it with 0 in each elements. It represent 26 alphabate in english language. use the method strupr() to convert the sentence in upper case. read each chracter of the sentence and if the character is a alphabate then get the ASCII of the character and deduct 65 [ ASCII of the A ] from it and store a variable x. Now increment the array position which index is x.
#includeint main() { char str[30],i; int ch[26]; for(i=0;i<26;i++) { ch[i]=0; } printf("Enter A String: "); gets(str); strupr(str); for(i=0;str[i]!='\0';i++) { if(str[i]>=65 && str[i]<=90) { ch[(str[i]-65)]++; } } printf("Result Is \n"); for(i=0;i<26;i++) { if(ch[i]>0) { printf("%c = %d\n",(i+65),ch[i]); } } return 0; }