Need Help writing a while loop condition

Feb 20, 2013 at 7:13pm
I am trying to write a program where I want to write a condition that would check if (num is greater than 5 away from distance)
and the second condition if (num is less than or greater to distance)

I am not sure how to include both of them in one for example this is what I currently have

while (num>5 && distance>5??)

if (num<=5 && distance<=5??)

I am not quite sure for the distance or if this is the correct way to write the condition.
Last edited on Feb 20, 2013 at 7:43pm
Feb 20, 2013 at 8:38pm
closed account (Dy7SLyTq)
while((num > distance + 5) || (num <= distance)
Feb 20, 2013 at 8:43pm
It seems to me that the way you're asking your question is good pseudo-code:

1
2
3
4

if( num > (  distance + 5 ) && num != distance )
    /*    do something    */


Feb 20, 2013 at 8:45pm
Same question you asked in another thread:
http://cplusplus.com/forum/beginner/93257/

Please keep the same question to a single thread.
Topic archived. No new replies allowed.