Here is my code
Code:
#include <stdio.h>
#include <stdlib.h>
const int QUARTER = 25;
const int DIME = 10;
const int NICKEL = 5;
const int DOLLAR = 100;
int main()
{
float cost; //Define the cost as float
float paid; //Define payments as float
char ch;
float sum;
int sum2;
int amount, dollars, quarters, dimes, nickels, pennies;
printf("Total Cost: ");
scanf ("%f", &cost);
printf("Paid: ");
scanf("%f", &paid ) ;
sum = paid - cost; //Subtract payments from the cost
//printf ("\n%.f dollars", sum);
printf ("\n\n-------------");
printf ("\n%.2f Result", sum);
printf ("\n-------------");
amount = sum * 100;
quarters = amount / QUARTER;
amount = amount % QUARTER;
dimes = amount / DIME;
amount = amount % DIME;
nickels = amount / NICKEL;
pennies = amount % NICKEL ;
printf("\n\n%d quarters\n%d dimes\n%d nickels\n%d pennies\n",
quarters, dimes, nickels, pennies);
printf("\n\nContinue? (y/n)");
while(kbhit()) getch(); /* clear the input buffer */
do ch = getch(); while(ch!='y' && ch!='n');
while(ch=='y');
return 0;
}