Write a program that tells what coins to give out for any amount of change
How can we create a program that determines the coins to give out for any amount of change using quarters, dimes, and pennies?
void computeCoin(int coinValue, int& number, int& amountLeft); To create a program that determines the coins to give out for any amount of change using quarters, dimes, and pennies, we can utilize the function computeCoin. This function takes in the coin value, the reference to the number of coins, and the reference to the amount left after deducting the coins used. For example, if we have an amount of 86 cents, we can initially call computeCoin with the value of 25 (quarters) and the amountLeft as 86. After this call, the number variable will be assigned the value 3 (representing 3 quarters), and the amountLeft variable will be assigned the value 11 (since 3 quarters amount to 75 cents, so we have 11 cents left). By iterating through the coin denominations of quarters, dimes, and pennies, we can determine the optimal combination of coins to give out for any input amount of change.