Introduction to Jumping Statement
Loop Control Statements − break and continue
C language provides us multiple statements through which we can transfer the control anywhere in the program.
There are basically 3 Jumping statements:
1. break jumping statements.
2. continue jumping statements.
3. goto jumping statements.
4. return Statement
Goto Statements
By using this jumping statements we can transfer the control from current location to anywhere in the program.
To do all this we have to specify a label with goto and the control will transfer to the location where the label is specified.
Syntax:
<label>: statement goto <label>;
Note :
It is good programming style to use the break, continue and return instead of goto.
However, the break may execute from single loop and goto executes from more deeper loops.
return statement
return statement is used to transfer program’s control from called function to calling function, it’s secondary task is to carry value from called function to calling function.
If function’s return type is void, you can use return only to return program’s control to the calling function, and if there is a return type you will have to return same type of value to the calling function.
Syntax:
return; Or return (value)