Need Help writing a while loop condition

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
closed account (Dy7SLyTq)
while((num > distance + 5) || (num <= distance)
It seems to me that the way you're asking your question is good pseudo-code:


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

Same question you asked in another thread:

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