The purpose of the loop structure is to reduce repeated code and reduce the burden on programmers. There are three forms: for loop, while loop, and do-while loop. Here we will also talk about the goto statement. in as, the goto statement has been converted into a very simple and visualized one. when programmers program in advanced languages, they are very abstract. goto statements are divided into gotoAndPlay and gotoAndStop in. the following parameters are frame labels or frames. here we are talking about programming, rather than simply referring to as. So let's talk about the use of goto in vc and vb. (If you do not like these friends, you can skip them)
InC languageIs an unconditional exclusive statement, the general form is:Goto statement label;The statement label is represented by an identifier. Its naming rules are the same as the variable name, which consists of letters, numbers, and underscores. The first character must be a letter or underline. Integers cannot be used as the label.Visual basic (vb)Divide the goto statement into the fourth structure, namely the redirection structure. syntax format: goto {line number/line label} The Line label must start with an English letter and end. the row number is not followed by a number: the function of the goto statement in both C and vb is the same,When the program is running, once a Goto statement is encountered, it is transferred to the row number or line label, and the corresponding program is executed at the statement label.Note:The structured program design method restricts the use of the goto statement, because misuse of the goto statement will make the program flow irregular, poor readability. however, it is not absolutely forbidden to use the goto statement. Generally, there are two purposes: 1) and if statements constitute a loop structure. 2) jump from the circulatory body to the external body. howeverC languageThe break statement and the continue statement can be used to exit the current layer loop and end the current layer loop. The use of the goto statement is greatly reduced, the goto statement is used only when the inner loop of a multi-tier loop jumps out of the outer loop. however, this usage is not in line with the structured principles and is generally not suitable for use. It is used only when it is a last resort or greatly increases program efficiency.
The basic format of the for loop is as follows:For (expression 1; expression 2; Expression 3) {statement Group}The statement group in braces can also be a statement. The execution process is as follows:1) first solve the expression 1. 2) solution expression 2. If the value is true (the value is not 0), execute the embedded statement (statement group) specified in the for statement, and then execute step 3rd. if the value is false (the value is 0), the cycle ends and the process is forwarded to step 5th. 3) solution expression 3 4) switch back to step 2 to continue the execution (a loop) 5) The Loop ends and the following statement of the for statement is executed.The simplest form of for statement is as follows:For statementSee figure!
Tired, smoke and write again. By the way, I 'd like to explain it.