Cannot figure out how to properly increment a variable inside of a while loop, C

前端 未结 2 1061
醉梦人生
醉梦人生 2021-01-29 12:30

EDIT: After re-writing my code in my IDE, for the 8th time today, I have made rookie mistake of giving my inputs a false data type, that has been fixed but my outputs still are

2条回答
  •  醉梦人生
    2021-01-29 13:19

    Here's the problem: There are 4 loops, one for quarters, one for dimes, one for nickels, and one for pennies. The first loop condition is correct:

    while (cents >= 25)
    

    The other three are incorrect:

    while (cents > 10)
    while (cents > 5)
    while (cents > 1)
    

    These all need to be changed to use >= in place of >.

提交回复
热议问题