C - Statement goto Statement

Introduction

goto statement directs the flow of statements to change unconditionally.

The goto statement jumps to a statement label.

A statement label is defined the same way as a variable name.

Label is a sequence of letters and digits, and the first of which must be a letter.

The statement label is followed by a colon : to separate it from the statement it labels.

goto statement ends with a semicolon:

goto there;

The following code marks code with label and then check the value of x.

If x is less then 0 it jumps to there.

there: x = 10;                    // A labeled statement

if(x < 0){
 goto there;
}