Site icon TestingDocs.com

How to read values into an array using RAPTOR

Introduction

In this post, we will learn how to read values into an array using a RAPTOR flowchart. We will prompt the user to enter marks for a student in five 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 five different subjects: English, Mathematics, Physics, Chemistry, and 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. If the condition is No, the loop is evaluated, and if it is true, it is executed. 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/

Exit mobile version