Sunday, 20 November 2016

Arrays

when storing a single number you would have declare one integer (Short) variable

to store 3 numbers you would need three variables

an array is a data structure that stores many items using a single variable

a single variable stores one single data item

an array is like lots of boxes held together

Dim numbers(4) as integer
Dim sNames(5) as string

the number in the brakets indicated the size of the array. We always start from zero

Exam marks(0) = console.readline
Exam marks(1) = console.readline
Exam marks(2) = console.readline
Exam marks(3) = console.readline
Exam marks(4) = console.readline

for Index = 0 to 4
    console.writeline(ExamMarks(Index))
    Next Index

the above section of code will print out every time in the array

array processings makes use of for loops

how to enter into an array

for Index = 0 to 4
    console.writeline("Enter exam mark numbers" & Index)
ExamMarks(Index) = console.readline

   Next Index



No comments:

Post a Comment