I have a loop which calculates a sum. I need it to stop when it equals 0. [ i have managed to do this with an if and break statement].
BUT if the sum never equals 0, I need the loop to stop when the answer is CLOSEST. I tried using [ if (sum >0) break;] BUT the loop only stopped at the FIRST integer >0, not the integer CLOSEST to zero.
So basically I ahve a loop and I want to search for the lowest integer > 0
I dont HAVE to use a break, if you can suggest something better I will use that
What are your validations in the loop then? There are lots of ways to control a loop statement without using the break keyword. If you post your code, then it'll be easier to walk you through.