Upcoming SlideShare
×

# Arrays

1,044 views
907 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
1,044
On SlideShare
0
From Embeds
0
Number of Embeds
24
Actions
Shares
0
40
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Arrays

1. 1. ARRAYSA WHOLE HEAP OF BUCKETS
2. 2. One Variable Can Only Hold One ThingI’m holding the name DAVE Name
3. 3. One Variable Can Only Hold One Thing DON’T TRYI’m holding AND PUT the name ANOTHER DAVE NAME IN Name ME!
4. 4. An Array is Different kind of VariableI’m holding I’m holding I’m holding the name the name the name DAVE ADAM CLEM 0 1 2 Name
5. 5. An Array is Different kind of VariableAn array is a set of values that are logically related to each other, such as the number of students in each grade in a grammar school. 0 1 2 Name
6. 6. An Array is Different kind of VariableAn array is like many buckets stuck together 0 1 2 Name
7. 7. An Array is Different kind of Variable An Array has many compartments to hold dataThe array below has 3 compartments. It can hold 3 pieces of data 0 1 2 Name
8. 8. An Array is Different Each compartment is labelled The labelling starts from 0Index 0 Index 1 Index 2 0 1 2 Name
9. 9. An Array is Different You can access different parts of the array by referencing the correct index numberIndex 0 Index 1 Index 2 0 1 2 Name
10. 10. Arrays In VB Declaring the Declaring the Declaring the data type of the Array size of the Array Array, in this case a String Dim names(3) As String names(0) = "DAVE" Declaring thecontents of the names(1) = "ADAM" Array names(2) = "CLEM"
11. 11. Arrays In VBDim names(3) As String names(0) = "DAVE" names(1) = "ADAM" names(2) = "CLEM" Console.WriteLine(names(0)) Console.WriteLine(names(1)) Console.WriteLine(names(2)) Writing the contents of the Console.ReadLine() array to the console.
12. 12. Arrays In VBDim names(3) As String names(0) = "DAVE" names(1) = "ADAM" names(2) = "CLEM" Console.WriteLine(names(0)) Console.WriteLine(names(1)) Console.WriteLine(names(2)) Console.ReadLine() Erasing the contents of theErase names Array
13. 13. Arrays and WHILEModule Module1 The while loop will Sub Main() look at every Dim names(3) As String compartment of names(0) = "DAVE" the names array names(1) = "ADAM" names(2) = "CLEM" Dim i As Integer = 0 While i < names.Length - 1 Console.WriteLine(names(i)) i = i + 1 End While Console.ReadLine() End Sub
14. 14. Arrays and WHILEModule Module1 Sub Main() Dim names(3) As String names(0) = "DAVE" names(1) = "ADAM" names(2) = "CLEM" Dim i As Integer = 0 While i < names.Length Console.WriteLine(names(i)) i = i + 1 End While Console.ReadLine() End Sub