C Error: declaration shadows a local variable — Won’t let me repeatedly replace the value of my float variable

Replace float cents = with cents = in your while loops. Currently you’re trying to declare a new variable cents which shadows the existing one. Technically this is valid C, perhaps your compiler (thankfully) has this warning set to an error? Note that you could optimise much of your logic to O(1) using integer division and careful checking with your debugger. Repeatedly subtracting from a value is … Read more

What is signed integer overflow?

Your while condition will always be true, meaning the loop will run forever, adding 1 to c in each iteration. Since c is a (signed) int it means it will increment slowly to its max value, and after that the next increment would be UB (undefined behavior). What many machines will do in this specific UB is to turn c negative, which I … Read more