We have already studied conditional statements (if..else
if..else), so you might be wondering what exactly a conditional
expression is. Think about it for a minute--what is the difference
between a statement and an expression?
Click here for the answer
Thus, a conditional expression can be used in any context where a
value is needed. Take a look at ``cond.c'' in your examples directory
(or view it directly) for a
striking example.
Notice that the argument to ``printf'' is a conditional expression,
where the value of the expression is a string! What would be involved
in rewriting this program to use a conditional statement?
Click here for the answer
Hamlet Project
hamlet@cs.utah.edu