### function that takes coins away from a change amount

I have completed the rest of my code but I cant make a function that allows an input value CHANGE, to be calculated in coins.

Example:

input 184 cents to make change for.

Takes the least amount of coins (Quarters, dimes, nickels, pennies from the amount inputted into a struct called coinbox)

So for 184 it should be

7 quarters
1 nickel
4 pennies

 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` ``````void make_change (coinbox& c, int amount) { int change; change=0; int quarter, dime, nickel, penny; quarter=25; dime=10; nickel=5; penny=1; cout << "Enter the amount to make change for: "; cin >> change; cout << "\n\n"; amount=change/quarter; if(amount>=c.quarters) {amount=change/c.quarters*quarter; c.quarters==change/c.quarters*quarter;} cout << amount << endl; cout << "Change made: "<< endl; cout << " Quarters: "<< c.quarters << endl; cout << " Dimes: "<< c.dimes << endl; cout << " Nickels: " << c.nickels << endl; cout << " Pennies: " << c.pennies << endl; cout << endl; cout << endl; }``````
Last edited on
Try making your own and post what you got. Part of being a programmer is solving algorithms.
Sorry, thank you. I've been trying to do this for a while thats why I am asking
Topic archived. No new replies allowed.