while loop conditions

I am having a hard time coming up with a solution on how to write my conditions for my while loop.

The while has to terminate when both x and y equals start_x and start_y.

So terminate when x = start_x and y = start_y..

the way i've done it now is by
while(x != start_x && y != start_y)
which terminates when one of the equals each other.. Any one with a solution??
You decided that your condition should be
when x = start_x ...
But you are using x != start_x . Why?
The while loop has too loop while
the x and y coordinates doesn't match start_x , start_y.
When i use this
while(x != start_x && y != start_y)
and lets say that start_x = 0, and start_y= 0
The while loop will terminate when x = 0 , and y = has some random value.
I want it to terminate when x=start_x and y = start_y.



You say, you need to use equal (==) in your condition, but in your code you are using not equals (!=). Why did you place != in your code?
The while has to run while they are not equal and terminate when they are equal...

terminate when they are equal...
(x == start_x && y == start_y)
run while they are not equal
(not (x == start_x && y == start_y) )
Applying DeMorgan laws, we get (x != start_x || y != start_y)
Topic archived. No new replies allowed.