#include <stdio.h>
int main() {
char s[1000];
int digitFreq[10] = {0}; // Array to store frequency of digits (0-9)
int i;
printf("Enter a string: ");
fgets(s, sizeof(s), stdin);
// Iterate through each character of the string
for (i = 0; s[i] != '\0'; i++) {
if (s[i] >= '0' && s[i] <= '9') {
// If the current character is a digit, update its frequency
digitFreq[s[i] - '0']++;
}
}
// Print the frequency of each digit
printf("Frequency of digits:\n");
for (i = 0; i < 10; i++) {
printf("Digit %d: %d\n", i, digitFreq[i]);
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: