The source codeThis is the "pset1" cash assignment. When the user input is and odd number except ending with 5, the code doesn't return anything. Other than that, it works well.

  • please refrain from posting images of code, and post your code here directly in the future.
    – UpAndAdam
    Commented Apr 29 at 15:14

1 Answer 1


Something was overlooked. It works when cash is a multiple of 5 because the code doesn't correctly handle the last few pennies.

Look at the last if block, lines 35 to 37. This code correctly adds the number of remaining pennies, but it doesn't change the value of remainder. Since remainder is still more than 0, the loop continues running. It's an infinite loop when the user input isn't divisible by 5.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thanks, I've modified it and it works. Commented Apr 29 at 0:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .