I have a function that is supposed to iterate a payment amount until it equals another variable amount. I think I'm misunderstanding something about while loop mechanics. Can someone please tell me why its not working?
When I debug, the loop takes in the variable values correctly: interest, salary, and the variable values all show as local values. But the guessPay doesn't increase, and the inSalary doesn't increment up.
In the future, please put your code in [code][/code] tags.
You're division to calculate guessPay is incorrect. Division has a higher precedence than subtraction, so you divide (inSalary * i) by 1 (accomplishing nothing), before subtracting the result of the pow() function. This might not be the source of your problem, but you probably want to fix it.
Sometimes a redefinition helps instead of an incremental value. Should be the same result as what you were looking for.
I've found that when using increments and decrements, you have to have ++ or -- to make them work properly. When I want to increase through multiplication or addition, the most fool-proof way to do it is through the use of parentheses and redefinitions.
Thanks both of you for the help. On a whim, I closed Visual Studio 2010 and reopened it. I think I had some other file loaded that was causing problems. Its working now, with the repair Zhuge suggested.