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

S

spasmous

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.
 
S

spibou

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 ?
 
S

spasmous

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!
 
J

John F

spasmous said:
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 ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,520
Latest member
KrisMacono

Latest Threads

Top