Tuesday, December 14, 2010
【 Weak current College 】 MCU c language tutorial-lesson eight: the statement (3)-conditional statement 】
See the topic after I believe we all probably the concept of conditional statements. Yes, just as the criteria in learning languages, C language statement as is, "If XX on XX" or "If XX XX on XX otherwise". That is when the conditions when executing statements. Conditional statement is also known as branch statement, if the keyword is. C language provides three forms of conditional statements:
1: if (conditional expression) statement
When the conditional expression evaluates to true, execute the statement, otherwise skip it.
Such as if (a == b) a + +; When a equal to b, a, plus 1 2: if (conditional expression) statement 1
Else statement 2
If the condition expression is set up executed statement 1, otherwise you perform statement 2
Such as if (a == b)
a++;
else
a--;
When a equal to b, a, a-1, plus 1. 3: if (conditional expression) statement 1
Else if (condition 2) statement 2
Else if (conditional expression) statement 3
Else if (conditional expression m) statement n
Else statement m
It is composed by the if else statement, the nested using to implement multiple direction conditional branch, use the if and when that else pairing, if less a syntax error will remember else always and most adjacent if matching.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment