Loops and arrays
-
Upload
abha-aggarwal -
Category
Education
-
view
118 -
download
0
Transcript of Loops and arrays
![Page 1: Loops and arrays](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/1.jpg)
![Page 2: Loops and arrays](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/2.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/3.jpg)
DO LOOP
![Page 4: Loops and arrays](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/4.jpg)
DO WHILE
![Page 5: Loops and arrays](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/5.jpg)
DO UNTIL
![Page 6: Loops and arrays](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/6.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/7.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/8.jpg)
FLOW CHART OF ARRAY
![Page 9: Loops and arrays](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/9.jpg)
![Page 10: Loops and arrays](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/10.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/11.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030211/58a1a0061a28abe6468b47e5/html5/thumbnails/12.jpg)