#include <stdio.h>
#include <math.h>

/* the declaration of round is supposed to be in math.h,
but it's not, so you need the following to avoid an annoying
warning */
double round(double);

int print_change(double amount)
{
  int i;
  int cents = (int) round(amount * 100.0);
  int num_coins = 4;
  int coins[] = {25, 10, 5, 1};

  for (i=0; i<num_coins; i++) {
    while (cents >= coins[i]) {
      printf("%d\n", coins[i]);
      cents -= coins[i];
      if (cents == 0) {
	break;
      }
    }
  }
}

int combo_helper(int cents, int coins[], int num_coins)
{
  int coin, combos;

  if (cents < 0) {
    return 0;
  }
  if (cents == 0) {
    return 1;
  }
  if (num_coins == 0) {
    return 0;
  }
  coin = coins[num_coins-1];
  combos = combo_helper(cents, coins, num_coins-1) +
    combo_helper(cents-coin, coins, num_coins);
  return combos;
  
}

int combinations(double amount)
{
  int cents = (int) round(amount * 100.0);
  int num_coins = 4;
  int coins[] = {1, 5, 10, 25};

  return combo_helper(cents, coins, num_coins);
}

int main()
{
  int combos;
  double amount = 1.00;

  print_change(amount);
  combos = combinations(amount);

  printf("There are %d ways to make change for $%g\n", combos, amount);
}
