While Looping

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.
If I read your description correctly, for the first condition you want to check if the difference between num and distance is > 5.

So you want to take the difference between the two numbers.
I've used the _abs macro to take the absolute value of the difference since I assume the two numbers could be in either order.
 (_abs(num-dist) > 5) 

You say the second condition is "num is less than or greater to distance". I assume you mean > when you say "greater to", so the second condition is simply
 ( num != distance) 

Putting them together:
if ( (_abs(num-dist) > 5) && ( num != distance)  )

Topic archived. No new replies allowed.