Flowgorithm Read Numbers from File Example
In this tutorial, we will learn how to read numbers from a text file using an example Flowgorithm flowchart. Flowgorithm 3.0 supports File I/O.
The flowchart will read the numbers from the text file and populate them in the Integer array. The input filename is numbers.txt. We will then compute the average of the numbers. We will assume the file has five numbers.
Steps to create the flowchart.
Launch the Flowgorithm tool.
Declare the flowchart variables.
An array to hold the numbers in the file. Sum variable to hold the sum of the numbers.
Open the file in the Read mode. Enter the name of the filename and check the Read option.
Iterate and read the numbers in the file. Populate the array elements and accumulate the sum in the variable Sum.
Output the array elements and the Average of the numbers in the file.
The flowchart uses a display module to print all the array numbers to the console screen.
Create a function that takes an array parameter and displays the array elements.
That’s it. We have successfully read the numbers from the file, and populate an array with the numbers in the file. Calculated the sum and average of the numbers.
Flowgorithm flowchart tutorials on this website:
For more information on the Flowgorithm tool, please visit the official website at: