First, the break statement is usually used in loop statements and switch statements. When the break statement is used in do-while, for, and while loop statements, the program can terminate the loop and execute the statements following the loop, generally, the break statement is always associated with the if statement, that is, when the condition is met, it jumps out of the loop.
Example: main () {int I = 0; char c; while (1)/* Set loop */{c = '\ 0 '; /* assign initial values to the variable */while (c! = 13 & c! = 27)/* receive characters on the keyboard until press ENTER or Esc key */{c = getch (); printf ("% c \ n", c );} if (c = 27) break;/* determines that if you press Esc, The loop will exit */I ++; printf ("The No. is % d \ n ", I);} printf (" The end ");}
Note:
1) The break statement does not work for the if-else Condition Statement. Www.2cto.com
2) in a multi-tier loop, a break statement only jumps one layer outward.
Second, the function of the continue statement is to skip the remaining statements in the loop and forcibly execute the next loop. The continue statement is only used in loop bodies such as for, while, and do-while. It is often used together with the if Condition Statement to accelerate the loop. Example: main () {char c; while (c! = 13)/* loop */{c = getch (); if (c = 0X1B) continue; /* If you press the Esc key and do not output it, perform the next loop */printf ("% c \ n", c);}. In fact, continue skips one loop and subsequent statements, perform the next loop.
Third, the return Statement returns the value of the function to the main function. For example: int max (int a, int B) {if (a> B) return a; else return B;} This function returns the maximum value in a and B; the return Statement is generally in the form of a return expression or a return (expression)
From chaojie2009