You need to figure out what your code is doing inside. When debugging a program it is perfectly acceptable to put some extra code in the program to help figure out the problems. You can always take the extra code out before you're finished.
In this case, try inserting a couple of extra printf() statements to display the different values in your code. For instance, if you're counting the number of coins with an int called coins, try putting
printf("Coins=%i\n", coins); after any statement that changes the value of coins. Do the same for other values that could be causing problems.
That should get you started on finding the problem. You'll get a lot more out of this assignment if you find the problems this way.
If this answers your question, please click the check mark to accept this and remove the question from the unanswered pool. Let's keep up on forum maintenance. ;-)