sorry I didnt realize the link didnt work...
heres the code
Code:
#include <stdio.h>
#include <math.h>
void coin_change(double amount, int *quarters, int *dimes, int *nickels, int *pennies);
int
main()
{
double price, pay, coins = 0;
int dollars, *quarters, *dimes, *nickels, *pennies;
printf("Welcome to the COINCOUNTER >9000!\n");
printf("Input the amount due (0 to quit): ");
scanf("%lf", &price);
printf("Input the amount paid: ");
scanf("%lf", &pay);
printf("Your change is: \n");
dollars = ceil(pay - price);
printf("dollars: %d\n", dollars);
coins = pay - price - dollars;
coin_change(coins, quarters, dimes, nickels, pennies);
return (0);
}
void coin_change(double amount, int *quarters, int *dimes, int *nickels, int *pennies)
{
*quarters = amount/0.25;
amount = amount - 0.25 * (double)quarters;
*dimes = amount/0.1;
amount = amount - 0.1 * (double)dimes;
*nickels = amount/0.05;
amount = amount - 0.05 * (double)nickels;
*pennies = ceil(amount/0.01);
printf("quarters: %d\ndimes: %d\nnickels: %d\npennies: %d\n", *quarters, *dimes, *nickels, *pennies);
}