2nd week

Heya!

In this post, we’ll talk about flowchart and pseudo code in more detail.

infinity-1837436_1280

Do you know what is it called?

Yup, it’s a loop.

In algorithm, we can use loop to simplify the code.

In my previous post, we already know the flowchart symbols and function. If you don’t remember, just take a look again 🙂

To make a loop in a flowchart, we need the decision symbol.

main-qimg-259c5b7282a03acf01b325fe39083025-c

There are types of loop :

While loop

A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement.

Do while loop

A do while loop is a control flow statement that executes a block of code at least once, and then repeatedly executes the block, or not, depending on a given boolean condition at the end of the block

flowchart_structure_loop.png

This structure allows you to repeat a task over and over. The red chart above on the left does the task and repeats doing the task until the condition is false. It always does the task at least once. The green chart on the right checks the condition first and continues doing the task while the condition is true. In the green chart the task may not be done at all. You can also have the conditions reversed and your loop is still a structured design loop.

So, we can conclude :

  • Do while loop
    • Process before decision
      • which mean the process has occured before
  • While loop
    • Decision before looping
      • which mean the process never occur


We can also use loop in pseudo code, for example :

  • Do while

do

task

while ( condition := yes )

  • While

while ( condition := yes )

do task

// in pseudo code, we use ( := ) instead of ( = ) to give a value for any variable, while ( = ) is  used in Java language //


Ms. Citra told us that we are allowed to make a flowchart which has decision inside decision, and also looping inside looping. She used our daily routines as examples which is easier to understand.

We can use a gameplay of “flappy bird” or “super mario” as our example.When our game reached game over, there’s usually a “restart” button. In the flowchart, the restart button is a decision type cause it has yes or no value which is inside the loop of the success decision. Look at the flowchart below

flowchart game

We can also use loops to simplify the code of “Average of 100 Numbers”

Look at the flowchart below :

2018-08-22 (1)

By using loop, we don’t need to input number one by one manually, so overall loops are really useful to simplify the code.



Another example :




Self – Reflection :

I had to re – learn about looping to understand how to make a looping inside looping flowchart so I could make a flowchart for any problem given.

Special thanks to our lecturer, Mrs. Citra and Mr. Mychael.



Thanks for visiting my site, don’t forget to follow and leave a comment below.

Have a nice day 🙂



Thanks to sources :

https://en.wikiversity.org/wiki/Computer_Programming/Loops

http://cess.nyu.edu/cess-experiments/z-tree-cheat-sheet/ii-conditional-statements-and-loops/

https://www.rff.com/structured_flowchart.php

https://en.wikipedia.org/wiki/While_loop

https://en.wikipedia.org/wiki/Do_while_loop

http://basicpogramming.blogspot.com/2010/01/looping-flowchart-part-3.html

https://stackoverflow.com/questions/43697634/showing-nested-for-loops-in-a-flowchart

One thought on “2nd week

Leave a comment