trying to make change from the price of the item and the amount given. please help!!!
/*This lab will calculate and display change*/\
int twenties = 0,
tens = 0,
fives = 0,
ones = 0,
quarters = 0,
dimes = 0,
nickels = 0,
pennies = 0;
printf("\nPlease enter Price of Item:");
printf("\nPlease enter Amount Paid:");
/* Calculations for change*/
change = amt_paid - price;
printf("\nCHANGE = $ ");
if (change > 20)
else if (change > 10)
else if (change > 5)
else if (change > 1)
else if (change > .25)
else if (change > .10)
else if (change > .05)
else if (change > .01)
Peeps wonder why I sometimes come down on newbies, its not rying to be unkind... I am simply trying to say, "Think for yourself".
Think about it... how much is a quarter worth... 25 cents!
A dime... 10 cents!
I allways try to think for at leaste 5 minutes before posting... the apparent answer (such as 5 ints for each type of change) is uduslly not the correct one, try to train yourself to think about more efficient possibuilities and you will allways acheive.
- Written with a burnt hand.
think about it... its not hard, think, if you REALLY using your whole brain, cannot figure it out, then read the code, but if u CAN than dont read the code I give you.
Okay if u are readinf this u didnt get it:
use simple division.
You scan the privce into int cents.
then simply devide by the value of the coin...
cents / 25; // quarters
sometimes I feal as if the school system has truely failed us.
no offence to you.