Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Intention I will learn how to use an array to store data in a program.

Similar presentations


Presentation on theme: "Learning Intention I will learn how to use an array to store data in a program."— Presentation transcript:

1 Learning Intention I will learn how to use an array to store data in a program.

2 Analysis Design Implementation Testing Documentation Evaluation

3 How would you store the names of all pupils in the class in a program?

4 Array An array is a data structure (a list of data items).
All the items have the same data type. e.g. in VB to store 20 names in an array: Dim names(20) As String

5 Array Each item in an array is called an element.
Each element is identified by the variable name and an index (number) which identifies the position of the element in the array.

6 Think of Excel What is the value in A3? What is the value in B5?

7 Excel (modified) What is the value in names(7)? What is the value in ages(10)? names ages

8 SQA Reference Language for Array
With data (so can work out the data type): e.g. DECLARE someVals INITIALLY [4, 6, 1] Without data (so must state data type): DECLARE newVals AS ARRAY OF STRING INITIALLY []

9 SQA Reference Language for Array
1. DECLARE allCosts INITIALLY [ 7, 3, 5, 7, 9 ] 2. SET total TO 0 3. FOR index FROM 1 TO 4 DO SET total TO total + allCosts(index) 5. END FOR 6. SEND total TO DISPLAY

10 SQA Reference Language for Array
1. DECLARE allCosts INITIALLY [3, 5, 2] 2. SET total TO 0 3. FOR EACH cost FROM allCosts DO SET total TO total + cost 5. END FOR EACH 6. SEND total TO DISPLAY

11 Array in VB

12 Programming Tasks Complete the programming tasks on pages 76-79
Extension Task Set 7

13 Success Criteria I can use arrays to store data.


Download ppt "Learning Intention I will learn how to use an array to store data in a program."

Similar presentations


Ads by Google