Dome
# Include <windows. h> # include <stdio. h> int main () {int n = 7; number2: printf ("Hello world \ n"); If (n = 7) {n = 8; printf ("n = 7 start \ n"); goto number0; printf ("n = 7 end \ n ");} else {printf ("n = 8 start \ n"); goto number1; printf ("n = 8 end \ n");} number0: printf ("Hi number0 \ n"); goto number2; number1: printf ("Hi number1 \ n"); Number3: printf ("Number3 \ n "); system ("pause"); Return 0 ;}
Output result
Conclusion Analysis and advantages and disadvantages
The GOTO statement can be used to jump out of a deep nested loop.
The GOTO statement can jump back or forward and continue to execute.
Goto can only jump to the function body, but not to the function in vitro. That is, Goto has a local scope and needs to be in the same stack.
A goto statement label consists of a valid identifier and symbol ";". The identifier naming rule is the same as the variable name, that is, it consists of letters, numbers, and underscores, the first character must be a letter or underscore. After the GOTO statement is executed,ProgramIt jumps to the statement label and executes the subsequent statement.
Generally, the GOTO statement is used with the if Condition Statement. However, while the GOTO statement brings flexibility to the program, it also makes the program structure layers unclear and hard to read, therefore, use this statement properly.