# What does it means in C and wht simplest form of this statement will

Page 1 of 1

## 4 Replies - 475 Views - Last Post: 17 January 2013 - 10:51 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=307809&amp;s=1288886d19a4136d7226326bf30a037c&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 The_afridi

Reputation: 0
• Posts: 9
• Joined: 18-May 12

# What does it means in C and wht simplest form of this statement will

Posted 17 January 2013 - 10:39 PM

char opponent = (player == 'W')? 'B' : 'W';

i cannot understand that above statement in c and what will be its simplest form? and what is above statement called in c ? c??
Is This A Good Question/Topic? 0

## Replies To: What does it means in C and wht simplest form of this statement will

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 12315
• Posts: 45,414
• Joined: 27-December 08

## Re: What does it means in C and wht simplest form of this statement will

Posted 17 January 2013 - 10:44 PM

It's called the ternary operator, and is evaluated in the following way: (condition) ? true-value : false-value.

So if the player == 'W', then opponent is 'B'. Otherwise, the opponent is 'W'.

### #3 The_afridi

Reputation: 0
• Posts: 9
• Joined: 18-May 12

## Re: What does it means in C and wht simplest form of this statement will

Posted 17 January 2013 - 10:48 PM

ok sir but how it can be converted into if else statment?

### #4 jimblumberg

Reputation: 5487
• Posts: 17,063
• Joined: 25-December 09

## Re: What does it means in C and wht simplest form of this statement will

Posted 17 January 2013 - 10:48 PM

Quote

and what is above statement called in c ? c??

This is called a ternary operator.

Quote

its simplest form?

To me the simplest form would be an if/else statement.
char opponent;
if(player == 'W')
opponent = 'B';
else
opponent = 'W';

Jim

### #5 The_afridi

Reputation: 0
• Posts: 9
• Joined: 18-May 12

## Re: What does it means in C and wht simplest form of this statement will

Posted 17 January 2013 - 10:51 PM

thank you sir it was very helpful.