# help for my exam. easy question

• 04-15-2008
joker_tony
help for my exam. easy question
what does the question mark mean also what is the exclamation, and the colon.

Code:

```int a; a =(6>3) ? 3 ! =5 : 9; printf("%i",a);```

question #2

Also, i dont understand how this if... else can be the answer can someone explain this to me.
Code:

```a=(6>3) ? 3 !=5 : 9; answer if(6>3) a=3!=5; else a=a;```
• 04-15-2008
tabstop
The if-else means the same thing as the ?: ternary operator (I just like typing the word "ternary") -- except the last symbol should be 9.
• 04-15-2008
Dino
{ optional assignment = } conditional_expression ? true_expression : false_expression ;

If the conditional expression evaluate to true, then the "true_expression" following the question mark is evaluated. Otherwise, the "false_expression" following the colon is evaluated.

These things can nest and get ugly as well. Perhaps this is an extra credit question on your test: What will answer print as?

Code:

```         int answer ;         int a = 6 ;         int b = 8 ;         answer = (b > a) ? a < b ? 0 : 7 : b == a ? 1 : 5;            printf ("answer is &#37;d\n", answer) ;```
• 04-15-2008
Elysia
That's a clear abuse of the operator and should be avoided, just to be noted.
Todd is doing it on purpose to confuse and test! If you pass the test, then surely you shall pass your exam!
• 04-15-2008
dwks