6.1 Calculate multiples of 3

In this chapter, I will show you several examples on how to use the knowledge we have learnt before. These examples are of or close to real-world scenarios. If you haven’t done any programming before, those examples will help you to gain a good understanding on how programmers think and talk to computers.

• • •

5.4 Break and Continue

The concept

Sometimes, we don’t need to execute the whole loop. Just need run part of the loop and when certain things happen, we can break the loop. For example, when we want to search for a certain value in an array. In some other scenarios, we might want to quit our current single loop run but don’t want to abandon the whole loop. In those cases, we need to use keyword break and continue. Below is the sample code:

• • •

5.3 Using while loop

The concept

While loop is much less frequently used than for loop. But you will still find it useful in many scenarios. And it is easy to be understood. Here is the sample code:

• • •

5.2 Using for loop

The concept

One of the most powerful part of computer is it can perform repetitive tasks very efficiently. In order for computers to do that, we need to introduce loop.

• • •

3.8 Function overloading

The concept

Function overloading is one of the most important concepts in computer programming – and one of the most interviewed ones. The concept itself, is not very difficult though. Let’s have a look.

• • •