-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I want to know the trick of implementing condition operator or
(if()... else...).
Symbols to use:
~, !, ^,&, +, |, <<, >>.
NOt to use:
if statement,
loops,
and it should give same result as x?y:z gives.
Since the C language includes the trinary operator, if() statements, and loops,
and you can't have C without them, there's no obvious reason that you would need
to answer this sort of question. Just use the trinary operator, or an if()
statement.
OTOH, if this is /homework/, intended to exercise your knowledge of C, then the
artificial constraints on this problem are acceptable. What would /not/ be
acceptable, however, is for us to do your homework for you.
I'll give you a hint: For a limited subset of types for a, x, y, z
the expression
a = x ? y : z;
/can/ be rewritten within your stated constraints. Think logically, and limit
your answer to a suitable subset of types, and you'll be able to figure it out
on your own.
- --
Lew Pitcher
IT Specialist, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFDnaPbagVFX4UWr64RAtrZAKCYjPdgJ2QunwVGC/vkYxIJVbZ93ACfSwsy
uXtEJRFSvGPUh4S2oXOGMKQ=
=zAuG
-----END PGP SIGNATURE-----