Conditional expression:
Expression 1-expression 2: Expression 3
(1) The order in which the conditional expression is executed: first, the expression 1 is solved, if it is not 0 (true), the expression 2 is evaluated, and the value of the expression 2 is the value of the entire expression. If the value of expression 1 is 0 (false), the expression 3 is solved, and the value of expression 3 is the value of the entire conditional expression.
(2) The conditional expression takes precedence over the assignment operator, max= (a>b)? A:B first solves the conditional expression in the assignment to Max.
(3) The binding direction of the conditional expression is "from right to left" such as: A>b? A:c>d? C:d supposed to be a>b? A: (c>d?) C:D)
(4) The conditional expression can also be written in the following form: A>b? (a=100): (b=100) expression 2 and expression 3 can be not only a numeric expression, but also an assignment expression or a function expression.
(5) In a conditional expression, the type of expression 1 can be different from the type of expression 2 and expression 3, such as: X. ' A ': ' B ' x is an integer variable, if x equals 0 The value of the expression is ' B '. The type of expression 2 and expression 3 can also be different, when the type of the conditional expression is the higher type. such as: X>y. 1:1.5 if x<=y, then the value of the conditional expression is 1.5, if x>y, the value should be 1, because 1.5 is solid, higher than the integer type, so 1 is converted to 1.0.
(6) Example: Enter a character to determine whether it is a capital letter, if it is, convert it to lowercase letters; And then output the resulting character.
Main ()
{
Char ch;
scanf ("%c", &ch);
Ch= (ch>= ' A ' &&ch<= ' Z '). (ch+32): ch;
printf ("%c/n", ch);
}