Information
Here are some example inputs and outputs:void calculate_coins(int value, int num_coins);
Example 1:
Example 2:Output:calculate_coins(500, 15); /* Specify amount in cents */You can make $5.00 with 5 halves 10 quarters You can make $5.00 with 7 halves 5 quarters 2 dimes 1 nickel You can make $5.00 with 8 halves 2 quarters 5 dimes You can make $5.00 with 8 halves 3 quarters 1 dime 3 nickels You can make $5.00 with 9 halves 4 dimes 2 nickels You can make $5.00 with 9 halves 1 quarter 5 nickels There are 6 possible ways to make $5.00 from 15 coins.
Example 3:Output:calculate_coins(1234, 35); /* Specify amount in cents */You can make $12.34 with 19 halves 11 quarters 1 nickel 4 pennies You can make $12.34 with 20 halves 8 quarters 3 dimes 4 pennies You can make $12.34 with 21 halves 6 quarters 2 dimes 2 nickels 4 pennies You can make $12.34 with 22 halves 3 quarters 5 dimes 1 nickel 4 pennies You can make $12.34 with 22 halves 4 quarters 1 dime 4 nickels 4 pennies You can make $12.34 with 23 halves 8 dimes 4 pennies You can make $12.34 with 23 halves 1 quarter 4 dimes 3 nickels 4 pennies You can make $12.34 with 23 halves 2 quarters 6 nickels 4 pennies You can make $12.34 with 23 halves 3 quarters 9 pennies There are 9 possible ways to make $12.34 from 35 coins.
Example 4:Output:calculate_coins(1234, 30); /* Specify amount in cents */You can make $12.34 with 24 halves 1 quarter 1 nickel 4 pennies There is 1 possible way to make $12.34 from 30 coins.
The name of the file should be coins.c and the command to compile it will look like this:Output:calculate_coins(1000, 15); /* Specify amount in cents */It is not possible to make $10.00 from 15 coins.
gcc -O -Werror -Wall -Wextra -ansi -pedantic main.c coins.c -o coins
Approximate number of lines of code: 20.
Notes
This will set the amount to $5.00 and the number of coins to 27. These values are passed to your function.coins 500 27
and here are some sample outputs for you to try:
Output for $1.00 and 10 coins (coins 100 10)
Output for $5.00 and 27 coins (coins 500 27)
Output for $8.13 and 40 coins (coins 813 40)
Thought Question: What happens if you accept any amount of money and any number of coins?