Skip to main content

Posts

Showing posts from July, 2015
You are given four integers 'a', 'b', 'y' and 'x', where 'x' can only be either zero or one. Your task is as follows: If 'x' is zero assign value 'a' to the variable 'y', if 'x' is one assign value 'b' to the variable 'y'. You are not allowed to use any conditional operator (including ternary operator).  Possible Solutions: 1. y = (1 - x) * a + x * b; 2.y = a ^ ((a ^ b) & (x))