If tmp is 0, the first clause is false, so the whole statement is false.
If tmp is 1, the first clause is true, and the second one is also true, so the whole statement is true.
If tmp is 5, the first clause is true, and the second one is false, so the whole statement is false.

Thanks for the reply. I was expecting that if tmp did NOT equal 0 OR tmp did NOT equal 5 then the condition would be true. In other words if tmp is anything other than 0 or 5 then do something.

No, it isn't. Instead of OR (||) in your statement, you need AND (&&).

Your statement should be

if(tmp != 0 && tmp != 5)
{
// Do this
}

0 is not not equal to 0, so that part is false, and the body is not executed.
1 is not equal to 0 and it is not equal to 5, so the body is executed.
2 is not equal to 0 and it is not equal to 5, so the body is executed.
3 is not equal to 0 and it is not equal to 5, so the body is executed.
4 is not equal to 0 and it is not equal to 5, so the body is executed.
5 is not equal to 0 and it is not not equal to 5, so that part is false, and the body is not executed.

Bryanpl:
Thanks. Both examples work. Much appreciated

There is a rule of boolean logic which explains why both work:

!A && !B == !(A || B)

That's why logic gate chips are usually all NAND and NOR gates. If you have a bunch of NAND gates (!(A&&B)) you can invert the inputs to make an OR gate.