Forth Lesson of Algorithm

Today’s material is basically the same with the previous one. Though this time, we learned some more things about repetition.

The first thing we learned is types of loop or looping. There are infinite loop and nested loop. Infinite loop is a looping method that doesn’t end. It can be ended if we use “break”. It happened because the looping doesn’t have a condition or an increment or decrement so the condition will always be True.

 

The second one is nested loop. Nested loop is a looping method within another loop. Just like nested if, nested loop uses another loop inside a loop.

 

We also learned about the difference between “while” and “do-while”. On “while” looping, the statements are done after checking the condition. Meanwhile, on “do-while” looping, the statements are done first, then it will check the condition. So, “do-while” looping will always did the statements at least once, but “while” looping might not did the statements at all.

 

We also learned about several ways to end repetition. First, by question. The program will ask users to continue doing the repetition or end it. The repetition will keep on repeating until user answer “end the repetition”. The second, by sentinel. The program will end the repetition when users input a special character, usually 0. The repetition will keep on repeating until user inputs the special character.

 

The last thing we learned is break and continue. Break is used to stop the repetition entirely. While continue is used to skip a part of the repetition and continue it on to the next repetition.

 

That’s all for this meeting. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *