SlideShare une entreprise Scribd logo
1  sur  14
ARRAYS
A WHOLE HEAP OF BUCKETS
One Variable Can Only Hold One
               Thing



I’m holding
 the name
   DAVE
               Name
One Variable Can Only Hold One
               Thing


                          DON’T TRY
I’m holding                AND PUT
 the name                 ANOTHER
   DAVE                    NAME IN
               Name          ME!
An Array is Different kind of Variable

I’m holding   I’m holding   I’m holding
 the name      the name      the name
   DAVE          ADAM          CLEM



      0             1           2

                Name
An Array is Different kind of Variable
An 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
An Array is Different kind of Variable

An array is like many buckets stuck together




      0              1              2

                 Name
An Array is Different kind of Variable
     An Array has many compartments to hold data

The array below has 3 compartments. It can hold 3 pieces
                        of data




       0                   1                   2

                      Name
An Array is Different
               Each compartment is labelled

                The labelling starts from 0


Index 0             Index 1             Index 2




          0                   1                   2

                        Name
An Array is Different
  You can access different parts of the array by referencing
                 the correct index number



Index 0              Index 1             Index 2




          0                    1                   2

                         Name
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 the
contents of the names(1) = "ADAM"
    Array
                names(2) = "CLEM"
Arrays In VB
Dim 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.
Arrays In VB
Dim 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 the
Erase names
                                        Array
Arrays and WHILE
Module 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
Arrays and WHILE
Module 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

Contenu connexe

En vedette

Sf Group Presentation
Sf Group PresentationSf Group Presentation
Sf Group Presentationlchetwynd
 
Melakukan perbaikan peripheral
Melakukan perbaikan peripheralMelakukan perbaikan peripheral
Melakukan perbaikan peripheralregianza
 
особливості реалізації основних положень концепції розвитку психологічної слу...
особливості реалізації основних положень концепції розвитку психологічної слу...особливості реалізації основних положень концепції розвитку психологічної слу...
особливості реалізації основних положень концепції розвитку психологічної слу...punkoff34
 
Психологічна допомога дітям у кризовому стані
Психологічна допомога дітям у кризовому станіПсихологічна допомога дітям у кризовому стані
Психологічна допомога дітям у кризовому станіpunkoff34
 
Master SmmUS 2015/2016 - Gestión de comunidades y crisis online
Master SmmUS 2015/2016 - Gestión de comunidades y crisis onlineMaster SmmUS 2015/2016 - Gestión de comunidades y crisis online
Master SmmUS 2015/2016 - Gestión de comunidades y crisis onlineXavi Marcé Vila
 
Melakukan perbaikan peripheral
Melakukan perbaikan peripheralMelakukan perbaikan peripheral
Melakukan perbaikan peripheralregianza
 
комп`ютерна залежність
комп`ютерна залежністькомп`ютерна залежність
комп`ютерна залежністьpunkoff34
 

En vedette (15)

Sf Group Presentation
Sf Group PresentationSf Group Presentation
Sf Group Presentation
 
If
IfIf
If
 
Select case
Select caseSelect case
Select case
 
Presentaci n1 (1)
Presentaci n1 (1)Presentaci n1 (1)
Presentaci n1 (1)
 
Reading in files
Reading in filesReading in files
Reading in files
 
Melakukan perbaikan peripheral
Melakukan perbaikan peripheralMelakukan perbaikan peripheral
Melakukan perbaikan peripheral
 
Savonuk
SavonukSavonuk
Savonuk
 
особливості реалізації основних положень концепції розвитку психологічної слу...
особливості реалізації основних положень концепції розвитку психологічної слу...особливості реалізації основних положень концепції розвитку психологічної слу...
особливості реалізації основних положень концепції розвитку психологічної слу...
 
Психологічна допомога дітям у кризовому стані
Психологічна допомога дітям у кризовому станіПсихологічна допомога дітям у кризовому стані
Психологічна допомога дітям у кризовому стані
 
Master SmmUS 2015/2016 - Gestión de comunidades y crisis online
Master SmmUS 2015/2016 - Gestión de comunidades y crisis onlineMaster SmmUS 2015/2016 - Gestión de comunidades y crisis online
Master SmmUS 2015/2016 - Gestión de comunidades y crisis online
 
Syntax errors
Syntax errorsSyntax errors
Syntax errors
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
Melakukan perbaikan peripheral
Melakukan perbaikan peripheralMelakukan perbaikan peripheral
Melakukan perbaikan peripheral
 
комп`ютерна залежність
комп`ютерна залежністькомп`ютерна залежність
комп`ютерна залежність
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 

Plus de Peter Andrews

Plus de Peter Andrews (8)

Trimming text
Trimming textTrimming text
Trimming text
 
Splitting up text
Splitting up textSplitting up text
Splitting up text
 
Is numeric
Is numericIs numeric
Is numeric
 
Loops
LoopsLoops
Loops
 
Collecting user input
Collecting user inputCollecting user input
Collecting user input
 
Variables
VariablesVariables
Variables
 
Hello world
Hello worldHello world
Hello world
 
Flow charts
Flow chartsFlow charts
Flow charts
 

Dernier

Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

Arrays

  • 1. ARRAYS A WHOLE HEAP OF BUCKETS
  • 2. One Variable Can Only Hold One Thing I’m holding the name DAVE Name
  • 3. One Variable Can Only Hold One Thing DON’T TRY I’m holding AND PUT the name ANOTHER DAVE NAME IN Name ME!
  • 4. An Array is Different kind of Variable I’m holding I’m holding I’m holding the name the name the name DAVE ADAM CLEM 0 1 2 Name
  • 5. An Array is Different kind of Variable An 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. An Array is Different kind of Variable An array is like many buckets stuck together 0 1 2 Name
  • 7. An Array is Different kind of Variable An Array has many compartments to hold data The array below has 3 compartments. It can hold 3 pieces of data 0 1 2 Name
  • 8. An Array is Different Each compartment is labelled The labelling starts from 0 Index 0 Index 1 Index 2 0 1 2 Name
  • 9. An Array is Different You can access different parts of the array by referencing the correct index number Index 0 Index 1 Index 2 0 1 2 Name
  • 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 the contents of the names(1) = "ADAM" Array names(2) = "CLEM"
  • 11. Arrays In VB Dim 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. Arrays In VB Dim 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 the Erase names Array
  • 13. Arrays and WHILE Module 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. Arrays and WHILE Module 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