# conditional operator

Page 1 of 1

## 3 Replies - 758 Views - Last Post: 16 February 2011 - 09:11 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=216373&amp;s=834eabe373f1553073bc04a3d9110ce8&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 tomdog51

Reputation: 0
• Posts: 48
• Joined: 30-November 10

# conditional operator

Posted 15 February 2011 - 04:28 PM

How do you write a conditional operator to determine which number
is smaller and which is larger. I can do it with an if /else statement but was told to try it with conditional operator.
Is This A Good Question/Topic? 0

## Replies To: conditional operator

### #2 barnwillyb

Reputation: 6
• Posts: 108
• Joined: 22-May 07

## Re: conditional operator

Posted 15 February 2011 - 04:34 PM

http://www.cplusplus...rial/operators/

• Changed Man With Different Priorities

Reputation: 952
• Posts: 2,364
• Joined: 15-February 11

## Re: conditional operator

Posted 16 February 2011 - 05:25 AM

```int a = 5, b = 6;
std::cout << (a < b ? "a" : "b") << " is larger";

```

• Saucy!

Reputation: 6219
• Posts: 23,965
• Joined: 23-August 08

## Re: conditional operator

Posted 16 February 2011 - 09:11 AM

First link in a Google search of conditional operator. It's also known as the ternary operator.