Without if...else

Hello,

I have a function that takes and argument int.
It receives only two values from the caller either 3 or 11.
If caller calls with 3 function should return 11 and vice-versa.

I used if ... else but my trainer says if--else should not be used.

How to do this

thanks & regards
Raghav
[337 byte] By [hraghavendra] at [2007-11-19 6:04:09]
# 1 Re: Without if...else
Have you heard of conditional operator?? Search in MSDN.

bashish
bashish at 2007-11-9 0:41:18 >
# 2 Re: Without if...else
One way:

int const f(int const i)
{
return (i + 8) % 16;
}
marten_range at 2007-11-9 0:42:19 >
# 3 Re: Without if...else
Maybe you should post what you have coded so far and we will work from there... ;)
Andreas Masur at 2007-11-9 0:43:23 >
# 4 Re: Without if...else
Another... :D

int foo(int i)
{
return (3^11)^i;
}
Kheun at 2007-11-9 0:44:18 >