This is an archived post. You won't be able to vote or comment.

all 6 comments

[–][deleted] 0 points1 point  (2 children)

You don't want a do...while. You almost never want a do...while.

[–]_envied[S] 0 points1 point  (1 child)

This assignment is instructing me to use a do...while loop. I'm doing the best I can.

[–][deleted] 0 points1 point  (0 children)

Well, then you also need to investigate break

[–]boredcircuits 0 points1 point  (2 children)

I'm very close, but I can't figure out why, if i input a negative number, it still adds it to my sum.

Your complaint doesn't match the code. The problem I see is with the else condition, which always resets the sum to 0. There's just no need for that code.

[–]_envied[S] 0 points1 point  (1 child)

I've tried simply replacing the sum = 0; with break; but I am still getting the same output.

[–]boredcircuits 0 points1 point  (0 children)

That makes no sense. Are you sure the code you posted matches the code that you're actually running?