473,574 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ihi = y[1]>y[2] ? (inhi=2,1) : (inhi=1,2);

Can someone tell me what the above is in "easy" C code, ie. using if
and else?

I think it's this:

if y[1]>y[2]
{
inhi=2;
ihi=1;
} else {
inhi=1;
ihi=2;
}

but I'm not sure. Thanks.

Jun 5 '06 #1
3 2076
ihi = y[1]>y[2] ? (inhi=2,1) : (inhi=1,2);
does indeed the same as
if y[1]>y[2]
{
inhi=2;
ihi=1;
} else {
inhi=1;
ihi=2;
}


Is it meant to be an entry for the obfuscated C-code competition
or something ?

Jun 5 '06 #2

sp****@gmail.co m wrote:
ihi = y[1]>y[2] ? (inhi=2,1) : (inhi=1,2);
does indeed the same as
if y[1]>y[2]
{
inhi=2;
ihi=1;
} else {
inhi=1;
ihi=2;
}


Is it meant to be an entry for the obfuscated C-code competition
or something ?


Thanks for the sanity check ;) More like a "Look at me, I can program
C!" competition!

Jun 5 '06 #3
spasmous wrote:
Can someone tell me what the above is in "easy" C code, ie. using if
and else?

I think it's this:

if y[1]>y[2]
{
inhi=2;
ihi=1;
} else {
inhi=1;
ihi=2;
}

but I'm not sure. Thanks.


Almost correct.
The first line should be
if( y[1] > y[2] )

I suppose you meant that.

And find a nice and handy (optionally verbal) stone to throw at the
person who wrote the original code ;-)

--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two.
Jun 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.