#include <stdio.h>
#include <string.h>
#include <conio.h>
#define STRSIZE 50
#define KARSIZE 52
char kar[KARSIZE] =
{‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’,
‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’,
‘y’, ‘z’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’,
‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’,
‘W’, ‘X’, ‘Y’, ‘Z’};
int jml[KARSIZE] = {0};
char str[STRSIZE];
void hitung(void);
int main(void) {
printf(“Masukkan kata: “);
scanf(“%s”, str);
hitung();
getch();
return 0;
}
void hitung(void) {
int l = strlen(str);
int i, j;
for(i = 0; i < l; i++) {
for(j = 0; j < KARSIZE; j++) {
if(kar[j] == str[i]) {
jml[j]++;
}
}
}
printf(“Jumlah huruf\n”);
for(j = 0; j < KARSIZE; j++) {
if(jml[j] > 0) {
printf(“ %c: %d\n”, kar[j], jml[j]);
}
}
}