#include
/*
Make Change.c
Written by Leland Batey
"Given an amount of change, how many different ways are there to return that amount of change? "
*/
int main(void){
/* Sorry for all these variables, but I'd really prefer to declare them here as one. */
int initCents, // The initial total of cents taken from the user.
maxQuarters, // The maximum number of whole quarters that can be taken from the initial amount of change given.
maxDimes, // The maximum amount of whole dimes that can be taken from the amount of change left over from taking out quarters
maxNickels, // The maximum amount of nickels that can be taken from the amount of change left over from taking out quarters and dimes
remainAfterQuarters, // The amount of change left over after taking that loops number of quarters
remainAfterDimes, // The amount of change left over after taking that loops number of quarters and dimes out of the initial amount
quarterCount, // The loop value for the number of quarters we have.
dimeCount; // The loop value for the dime counter.
//nickelCount; // The loop value for the number of nickles we have.
printf("Enter amount (in cents): ");
scanf("%i", & initCents); // Read in initCents as an integer.
maxQuarters = initCents / 25; // Only reading integers.
//printf("%i\n maxQuarters", maxQuarters);
printf("Quarters | Dimes | Nickels\n");
for (quarterCount = 0; quarterCount <= maxQuarters; quarterCount++){
remainAfterQuarters = initCents - ( 25 * quarterCount );
maxDimes = remainAfterQuarters / 10; // the max number of whole dimes that can be taken out of the change left over after taking quarters.
for (dimeCount = 0; dimeCount <= maxDimes; dimeCount++ ){
remainAfterDimes = remainAfterQuarters - ( 10 * dimeCount );
maxNickels = remainAfterDimes / 5; // Max number of whole nickles that can be taken out of the remaining change
printf("%8i | %8i | %8i\n",quarterCount,dimeCount,maxNickels );
}
}
return 0;
}