C Syntax - Control Structures - Jump Statements

Jump Statements

Jump statements transfer control unconditionally. There are four types of jump statements in C: goto, continue, break, and return.

The goto statement looks like this:

goto ;

The identifier must be a label (followed by a colon) located in the current function. Control transfers to the labeled statement.

A continue statement may appear only within an iteration statement and causes control to pass to the loop-continuation portion of the innermost enclosing iteration statement. That is, within each of the statements

while (expression) { /* ... */ cont: ; } do { /* ... */ cont: ; } while (expression); for (expr1; expr2; expr3) { /* ... */ cont: ; }

a continue not contained within a nested iteration statement is the same as goto cont.

The break statement is used to end a for loop, while loop, do loop, or switch statement. Control passes to the statement following the terminated statement.

A function returns to its caller by the return statement. When return is followed by an expression, the value is returned to the caller as the value of the function. Encountering the end of the function is equivalent to a return with no expression. In that case, if the function is declared as returning a value and the caller tries to use the returned value, the result is undefined.

Read more about this topic:  C Syntax, Control Structures

Famous quotes containing the words jump and/or statements:

    Some of these men had become abstrusely entangled with the spying departments of other nations and would give an amusing jump if you came from behind and tapped them on the shoulder.
    Vladimir Nabokov (1899–1977)

    If we do take statements to be the primary bearers of truth, there seems to be a very simple answer to the question, what is it for them to be true: for a statement to be true is for things to be as they are stated to be.
    —J.L. (John Langshaw)