Homework 2: Count Digit Occurrences in String

The program checks every character in the string. If the character is a digit from 0 to 9, it increases the count for that digit. At the end, it prints how many times each digit appeared.

Difficulty:
★★☆☆☆
#include 

int main()
{
    const char* str = "6480 89839 041710 90216";
    int count[10] = {0};
    int i = 0;

    while (str[i] != '\0') {
        if (str[i] >= '0' && str[i] <= '9') {
            count[str[i] - '0']++;
        }
        i++;
    }

    for (i = 0; i < 10; i++) {
        printf("%d: %d\n", i, count[i]);
    }

    return 0;
}