In this tutorial, we will look at a simple Flowgorithm flowchart example. We will design a flowchart to reverse a given number. Let’s first see a sample example input and output of the flowchart.
If the user provides the following input to the flowchart : 7836
The expected output of the flowchart is : 6387
DECLARE Integer number, digit, result
SET result = 0
DISPLAY “Please enter a number = “
DISPLAY “Given number = “, number
WHILE number >= 1
SET digit = number MOD 10
SET result = result * 10 + digit
SET number = number / 10
DISPLAY “Reverse of the number = “, result
Flowgorithm Flowchart Example
We will prompt the user for a number. We will store this in a variable number.
Using the WHILE loop statement, inside the loop:
We will extract each digit of the given number.
number MOD 10
This will give the last digit of the number. We will store this digit in a variable digit.
For example, 1345 MOD 10 will store 5 in the digit.
We will build the reverse of the number using the variable result
number / 10
We move to the next digit by dividing the number by 10.
number = 1345 / 10 will store 134 in the variable number.
When all the digits are covered in the number variable, it will become 0. The WHILE loop terminates as the loop condition is evaluated to False.
Run the flowchart and verify the output of the flowchart.
Flowgorithm flowchart tutorials on this website:
For more information on the Flowgorithm tool, please visit the official website at: