In the previous tutorial I discussed about 2 of the min transfer control statements named break and continue.
Now we are going to look further into control statements.
The return statements is related to functions and it is used to exit a method and optionally return a value to an expression.
If a function does not return a value, it must have the keyword void in the method declaration.
For example :
This line of code explain the way to use the return statement with an integer returning to the called expression.
Whenever you do not need to return you have to used void keyword in the function declaration.
Labelled statement is used in conjunction with break and continue statements. This can be used simply to jump over loops.
Check this out labeling with break statement:
You can observe that, at the break statement, it breaks the loop and jumps on to the top of the code and runs the code until all the conditions are unsatisfied.
Now see this example for labeling with continue statement :
Similar to break , the code acts the same with the continue.