More Transfer Control Statements (Returning & Labeling)

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:

With output
More zoomed image

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 :

With output
More zoomed view

Similar to break , the code acts the same with the continue.

Thank you.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s