How to read these flowcharts
The point of this page is not fancy theory. It is to help you rebuild a task block by block.
For each task, read the block order, sketch the main variables, and then draw the flowchart in your editor.
Start simple
Write the input and output blocks first.
Then loop
Add the loop only after the start values are clear.
Then test
Try the sample values listed under each task.
Greeting flowchart test
Use this tiny task when you want to remember the basic shape of a flowchart.
Block order
- Start
- Output: 'Hello'
- Input: read the user's name
- Output: 'Hello, name'
- End
Useful reminder
This task is good for the very first PS Diagram lesson.
Quick test
- The diagram should have exactly one input block and two output blocks.
- The second output must use the value from the input block.
Digit sum
The main idea is to take the last digit, add it, remove it, and repeat.
Block order
- Start
- Input: number
- Set sum = 0
- While number > 0
- digit = number % 10
- sum = sum + digit
- number = number / 10
- Output sum
- End
Useful reminder
Use integer division when you remove the last digit.
Quick test
- For 528 the sum should be 15.
- The loop must stop when the number becomes 0.
Reverse text
This flowchart is about index order. You start at the end and move left.
Block order
- Start
- Input: text
- Set result = empty string
- Set i = length of text - 1
- While i >= 0
- Add text[i] to result
- Decrease i by 1
- Output result
- End
Useful reminder
When you draw the loop, show both the index variable and the result string clearly.
Quick test
- abc should become cba.
- An empty string should stay empty.
Reverse number
This is similar to digit sum, but you build a new number instead of a sum.
Block order
- Start
- Input: number
- Set reversed = 0
- While number > 0
- digit = number % 10
- reversed = reversed * 10 + digit
- number = number / 10
- Output reversed
- End
Useful reminder
The multiplication by 10 must happen before you add the next digit.
Quick test
- 1234 should become 4321.
- 120 should become 21 if leading zeroes are ignored.
Sequence minimum and occurrence count
This is a common pattern: store the current best value, then update a counter.
Block order
- Start
- Input: count of numbers
- Read the first number and set it as min
- Set occurrenceCount = 1
- Repeat for the remaining numbers
- If value < min, set min = value and occurrenceCount = 1
- Else if value == min, increase occurrenceCount
- Output min and occurrenceCount
- End
Useful reminder
The first number is often handled before the loop so you have a valid starting minimum.
Quick test
- For 4, 2, 2, 9 the minimum is 2 and the count is 2.
- If the first value is already the minimum, the algorithm must still work.
Factorial
This task is just a product loop. Start with 1, not 0.
Block order
- Start
- Input: n
- Set result = 1
- Set i = 1
- While i <= n
- result = result * i
- Increase i by 1
- Output result
- End
Useful reminder
Show the loop condition clearly. A wrong loop start is the most common mistake here.
Quick test
- 5! should be 120.
- 0! should stay 1 if you allow zero.
Quadratic equation in flowchart form
The decision blocks are the key part here. One formula leads to three different cases.
Block order
- Start
- Input: a, b, c
- If a == 0, output 'Not quadratic' and stop
- Compute discriminant d = b^2 - 4ac
- If d < 0, output 'No real roots'
- Else if d == 0, compute one root
- Else compute two roots
- Output the result
- End
Useful reminder
Keep formulas inside process blocks and decisions inside diamond blocks.
Quick test
- Draw one branch for d < 0, one for d == 0, and one for d > 0.
- Do not forget the extra check for a = 0.
Greatest common divisor
This is one of the cleanest loop-based algorithms for a flowchart.
Block order
- Start
- Input: a, b
- While b != 0
- temporary = b
- b = a % b
- a = temporary
- Output a
- End
Useful reminder
Many people find it easier when the temporary variable is shown in its own block.
Quick test
- For 24 and 18 the result should be 6.
- The loop must stop when b becomes 0.
Decimal to binary
The remainder from each division becomes the next binary digit, but in reverse order.
Block order
- Start
- Input: decimal number
- Set binary = empty string
- While number > 0
- remainder = number % 2
- Put remainder in front of binary
- number = number / 2
- Output binary
- End
Useful reminder
If the input can be 0, add a special case before the loop.
Quick test
- 13 should become 1101.
- The remainder must be added at the front, not at the end.
Bubble sort
Bubble sort is not the fastest sort, but it is great for learning loop order and swapping.
Block order
- Start
- Input: list of values
- Repeat for pass = 0 to length - 2
- Repeat for i = 0 to length - 2 - pass
- If value[i] > value[i + 1], swap them
- After all passes, output the sorted list
- End
Useful reminder
If you draw a swap in one block, write it as temporary = a, a = b, b = temporary.
Quick test
- 3, 1, 2 should end as 1, 2, 3.
- The inner loop should get shorter after each pass.