1. Select Structure Statement
C # Selection Structure statement is mainly
if (judging condition) {
1
}
else{
2
}
Returns true when the condition in the if is satisfied execution 1, only if the condition in the if is not satisfied to return false execution 2
For example:
2. Looping statements
The loop statement is mainly divided into: While statement for statement Do...while statement These three kinds (for most commonly used)
(1). While statement
while (loop condition) {
1
}
How to meet the loop condition is always circulating (while thestatement is prone to form a dead loop )
This while is a dead loop.
(2). Do...while statements
do{
1
}
while (loop condition)
This statement is the same as the previous while statement
The difference is that the do...while is executed first 1 in the execution loop condition, while the while is the first execution of the loop condition in execution 1 (Do...while statement also easy to form a dead loop )
This statement is also a dead loop
(3) for loop (most commonly used)
For (initialize an expression; loop condition; action expression) {
1
}
This cycle is most commonly used (it is not as easy to form a dead loop as the two loops above)
This statement is not a dead loop.
(4). Loop inside can be set loop
For example:
3. Jump statements
It's mainly a break,continue.
(1). break
Jump out of the loop when executing to the break statement
Jump out of the loop when you're i=4
(2). Continue
When executing to the Continue statement, jump out of this loop
Jump out of this loop when you're i=4.
(3).
Continue and break they're the same way.
C # Select Structure statement and Loop statement