How to read values into an array using RAPTOR
Introduction
In this post, we will learn how to read values into an array using RAPTOR flowchart. We will prompt the user to enter marks for a student in 5 subjects. For this example, we will take a single dimensional array variable called marks. marks is an array variable that represents marks of a student called Alice in 5 different subjects like English, Mathematics, Physics, Chemistry, Biology.
Flowchart
The flowchart would prompt the user to enter 5 subject marks. the numbers are stored in an array variable marks. The numbers would be stored using the index variable. The index is assigned to 1 and controlled with a loop. The loop would quit once the index is greater than 5.
marks[1]
marks[2]
marks[3]
marks[4]
marks[5]
Loop condition
The loop is controlled using the loop condition. The loop condition is evaluated and the loop is executed if the condition is No. The index is incremented inside a loop.
index <- index + 1
The user entered values are stored using the array variable and the index inside square brackets.
marks[index]
Pseudocode
ReadArray() DECLARE index DECLARE marks() index = 1 DO UNTIL index > 5 PROMPT "Enter marks for Alice" INPUT marks(index) index = index + 1 LOOP END
Print the array
To print the values in the array we need to use a loop. Instead of reading the values we use the output statement to print the values of the array.
Raptor Tutorials on this website can be found at:
https://www.testingdocs.com/raptor-a-flowchart-tool/
RAPTOR official website: https://raptor.martincarlisle.com/