One, for statement, while statement, Do-while statement
1. Features
|
for |
while |
do-while |
|
0 |
0 |
1 |
judging mode |
Initialize-> first judge and execute |
|
first after the judgment |
Pros and cons |
more convenient to use when the loop is clear |
|
It will be executed at any time |
2.do-while statements are often used to resolve fragile input patterns
Char choice; Do { scanf ("%c", &while'y 'n');
3.do-while statement with a semicolon
Two, break statement and Continue statement
1. When the break statement is executed, just jump out of the layer loop that surrounds it recently
2.goto Keywords: More for exception handling, try not to use
Example: if (error) goto error;
error:printf ("Error");
Iii. Examples of procedures
1. Random number: rand () can generate an integer between 0~rand_max (0X7FF)
Header file: Stdlib.h set Seed: Srand ((unsigned) time (NULL)); Need to Time.h header file
C Language Learning notes-5. Cyclic structure programming