Jan 11, 2009

Write a function to implement a ternary operator a?b:c without using any conditional statements like if,for,while etc.. you are allowed to you any ope

Write a function to implement a ternary operator a?b:c
without using any conditional statements like if,for,while etc..
you are allowed to you any operators like &, |, ^ etc...
your function can use return statement.

int Ternary(int a, int b, int c)
{
return (a&b)|(!a&c);
}

No comments:

Post a Comment