loops and arrays

12

Upload: abha-aggarwal

Post on 13-Feb-2017

125 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Loops and arrays
Page 2: Loops and arrays

LOOPSLoop statement allow you to execute one or more lines of codes repeatedly, where the operations must be repeated over and over again.

TYPES

DO LOOPDO

WHILE

DO UNTIL

FOR NEXT

WHILE WEND

Page 3: Loops and arrays

DO LOOP

Page 4: Loops and arrays

DO WHILE

Page 5: Loops and arrays

DO UNTIL

Page 6: Loops and arrays

FOR…NEXT

• It requires that you know how many times the statement in the loop will be executed.

WHILE…WEND

• It executes a block of statements while a condition is True.

Page 7: Loops and arrays

ARRAYS

Array is a set of element of the same datatype represented by a single variable name.

Each element of an array has a unique identifying index number which is used for assessing the elements.

DECLARING AN ARRAY:

SYNTAX: Dim array name (array size) [as datatype]

Page 8: Loops and arrays

FLOW CHART OF ARRAY

Page 9: Loops and arrays
Page 10: Loops and arrays

TYPES OF ARRAY

ONE DIMENSIONAL

• Has only one index or subscript.• It is like a list of items that consists

of one rows and one column of item.

• Syntax: Dim array name (array size) as datatype

MULTI-DIMENSIONAL

• Have higher dimensions.• N-dimensional array can have n

dimensions.• Syntax: Dim array name

(index1, index2 – index n) as datatype

Page 11: Loops and arrays

STATIC

• Size always remain the same.

• Its size and dimensions are specified with its declaration.

DYNAMIC

• Size can be changed at run-time.

TYPES Cont..

Page 12: Loops and arrays