0% found this document useful (0 votes)
8 views1 page

Arrays

Uploaded by

Neil Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Arrays

Uploaded by

Neil Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Arrays

1D arrays

Arrays are a data structure that can store multiple values


They can be assigned to a single value
Made up of multiple slots each storing an item of data
Index – number which can be used to access that set of data

DECLARE NameOfTheArray : ARRAY[First Index Value : Last Index Value] OF DataType

DECLARE SaleItems : ARRRAY [1:5] OF STRING


DECLARE Counter : INTEGER

FOR Counter  1 TO 5
OUTPUT “Enter the Sale item “
INPUT SaleItems[Counter]
NEXT Counter

OUTPUT “List of items for sale are”


FOR Counter  1 TO 5
OUTPUT SaleItems[Counter]
NEXT Counter

// Declaration of variables
DECLARE Counter: INTEGER

// Display the details and check the valid data for 10 employees
FOR Counter  1 TO 10
//Display the data for each employee
OUTPUT “Employee ID”, EmpID [Counter]
OUTPUT “Employee Name”, EmpName [Counter]
OUTPUT “Department Name”, DeptName [Counter]

//Check if the Employee ID is valid


IF EmpID>=1 AND EmpID<=1000 THEN
OUTPUT “Valid Employee ID”
ELSE
OUTPUT “Invalid Employee ID” ENDIF
ENDIF

//Check if the Department Name is valid


IF DeptName= “Accounts” OR DeptName=“Sales” THEN
OUTPUT “Valid Department Name”
ELSE
OUTPUT “Invalid Department Name”
ENDIF
NEXT Counter

You might also like