how do you do a loop with specific irregular steps in c?

Thanks to @WeatherVane’s tip I could find a solution:

int calculateNumber(void)
{
    int coins[] = {25, 10, 5, 1};

    for (int i = 0; i < 4; i++)
    {
        numberCoins += change / coins[i];
        change = change % coins[i];
    }

    return 0;
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top