Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: intdollar, quarters, dimes, nickels, pennies; printf("Enter due amount: "); scanf("%d", &due); printf("Enter paid amount: "); scanf("%d", &amount); change(amount - due, &dollar, &quarters, &dimes, &nickels, &pennies); printf("Dollars: %d\n", dollar); printf("Quarters: %d\n", quarters); printf("Dimes: %d\n", dimes); printf("Nickels: %d\n", nickels); printf("Pennies: %d\n", pennies); return0; } //function defination void change(int amount, int *dollar, int *quarters, int *dimes, int *nickels, int *pennies) { *dollar = amount / 100; amount = amount % 100; *quarters = amount / 25; amount = amount % 25; *dimes = amount / 10; amount = amount % 10; *nickels = amount / 5; amount = amount % 5; *pennies = amount; }
Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies.
Ex: If the input is:
intdollar, quarters, dimes, nickels, pennies;
printf("Enter due amount: ");
scanf("%d", &due);
printf("Enter paid amount: ");
scanf("%d", &amount);
change(amount - due, &dollar, &quarters, &dimes, &nickels, &pennies);
printf("Dollars: %d\n", dollar);
printf("Quarters: %d\n", quarters);
printf("Dimes: %d\n", dimes);
printf("Nickels: %d\n", nickels);
printf("Pennies: %d\n", pennies);
return0;
}
//function defination
void change(int amount, int *dollar, int *quarters, int *dimes, int *nickels, int *pennies)
{
*dollar = amount / 100;
amount = amount % 100;
*quarters = amount / 25;
amount = amount % 25;
*dimes = amount / 10;
amount = amount % 10;
*nickels = amount / 5;
amount = amount % 5;
*pennies = amount;
}
This is not working, i keep getting errors
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images