Populate String Array with User Input
Overview
Earlier, we learned about Array in flowcharts. However, we have hardcoded the array elements. In this tutorial, we will learn how to populate a string array with user input. The contents in the array would be dynamic using this approach.
Flowgorithm Flowchart
The ‘fruits’ is the array variable. The array holds fruit names i.e String data type. The array size is 5.
The ‘index’ is the Array index variable. The legal values of the array index variable in this example are from 0 to 4.
Loops
The flowchart uses two ‘for loops’. The first loop is to populate the array contents from the user and the second loop to output the contents of the array to the console window. A for loop is used because we know the array size beforehand and how many times to iterate the loop.
For loop
Flowgorithm For Loop Statement
Sample Output
Execute the flowchart. Click on the Green run command to execute the flowchart.
The flowchart prompts the user to enter 5 fruit names. The names are stored in the fruits array.
Bad Subscript Error
The below sample error is when we attempt to store or access an array element that is not within the valid range:
—
Flowgorithm Tutorials
https://www.testingdocs.com/flowgorithm-flowchart-tutorial/
Flowgorithm Website: