> How can I write a program that determines all possible coin combinations given a number of coins?

How can I write a program that determines all possible coin combinations given a number of coins?

Posted at: 2014-12-18 
This is essentially a math problem. Look up "permutations" and there should be some mention of the mathematical equation to use to figure it out.

And from your output, it looks like you are expected to do a loop to demonstrate the different possible coins that can result. You may want to research the "while" loop

You don't expect me to write it for you, right? ;-)

I need help with this in C, where the user enters an integer for 'n' (number of coins) and the computer returns an output of all the combination that number of coins can make.

Example:

//User enter 2

Enter n: 2

//Outputs

0 quarters 0 dimes 0 nickels 2 pennies

0 quarters 0 dimes 1 nickels 1 pennies

0 quarters 0 dimes 2 nickels 0 pennies

0 quarters 1 dimes 0 nickels 1 pennies

0 quarters 1 dimes 1 nickels 0 pennies

0 quarters 2 dimes 0 nickels 0 pennies

1 quarters 0 dimes 0 nickels 1 pennies

1 quarters 0 dimes 1 nickels 0 pennies

1 quarters 1 dimes 0 nickels 0 pennies

2 quarters 0 dimes 0 nickels 0 pennies