The Conditional Operator

I l @ ve RuBoard

The Conditional Operator

? : takes three operands, each of which is an expression. They are arranged this way: expression1 ? expression2 : expression3 . The value of the whole expression equals the value of expression2 if expression1 is true, and equals the value of expression3 otherwise .

Examples

( 5 > 3 ) ? 1 : 2 has the value 1 .

( 3 > 5 ) ? 1 : 2 has the value 2 .

( a > b ) ? a : b has the value of the larger of a or b .

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net