XOR and XNOR operations with 2 or 3 inputs

Hm...

if ((x != y) || (y != z)) { // three input XOR 
  // user code
}

x = 0;
y = 1;
z = 1;

This will pass your test because x != y, and the y != z term won't be evaluated since in C the '||' operator means 'or' and not 'xor'. But 011 doesn't strike me as something that should trigger a 3-input hardware XOR gate...

Maybe you mean:

if ( (x || y || z) && !( (x && y) || (y && z) || (x && z) ) )

Assuming you're OK with that logic as-is...

If you really want to treat these values as booleans (since that is not a native type in C), you'll probably want to mask them:

if (( (x & 1) != (y & 1) ...

Otherwise, consider inputs of 5, 10, and 0. While 5 and 10 both evaluate to "true" in an actual boolean context, they won't be equal, and so will not evaluate in the spirit of your conditional statement.

Even this result is subject to interpretation though. Afterall, 5 & 1 evaluates to 1, while 10 & 1 evaluates to 0. Is that correct? Or do you really mean if ( ( (x || y) && !(x && y) ) || ( (y || z) && !( y && x) ) ) or something similar?

If the latter, it might be easier to just pre-condition the variables:

x = (x) ? 1 : 0;
y = (y) ? 1 : 0;
z = (z) ? 1 : 0;

Obviously if you're trying to write tight loops with as few operations as possible, which way you go depends on how many conditions are evaluated and whether you can trust the values to be constrained to 0 || 1.