I need to solve the following problem:
Write a program that asks the user to enter a U.S. dollar amount and the shows how to pay that amount using the smallest number of $20, $10, $5 and $1 bills.
I don't know how to extract the change of the first dividing bill to 20 amount and after to continue with 10, 5 and 1.
I had written the following code but is not solving my quest:
#include <stdio.h>
int main(void)
{
int value1, value2, value3, value4, bill, change;
printf("Put the bill value: ");
scanf_s("%d", &bill);
value1 = bill/ 20;
rest = bill- (bill/ 20);
value2 = bill /10 // Tried with this but not working:(bill-(bill/20))/10;
value3 = bill/ 5;
value4 = bill/ 1;
printf("The amount is: %d$. \n", bill);
printf("change=%d", change);
/*printf(" $20 Bill: \n", value1);
printf("$10 Bill: \n", value2);
printf("$5 Bill: \n", value3);
printf("$1 Bill: \n", value4);*/
return 0;
}
It would help me a lot if you could explain to me how to solve correctly this problem.