Goal: - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Goal:

Description:

do able, but tiring...what if you want to store 100 students? 1400? Array (Static) Need to be able to store many data items of the same type efficiently. ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 6
Provided by: nhsNeedh
Category:
Tags: goal | tiring

less

Transcript and Presenter's Notes

Title: Goal:


1
Goal
  • We would like to store the grades of 25 students
  • var
  • i1,i2,i3,i4,i5,i6....i25 Integer
  • ...do able, but tiring...what if you want to
    store 100 students? 1400?

2
Array (Static)
  • Need to be able to store many data items of the
    same type efficiently . . . we can't create
    hundreds of variables.
  • . . . we need Arrays
  • Var
  • myArray Array1..100 of integer
  • //allocated space for 100 integers
  • myList Array1..25 of String //array of str

3
Usage
  • Use the arrays just like any other variable,
    only, you need the variable name and index
  • myArray1 10
  • myArray8 MyArray9
  • myArray25 Random(10)1

4
Example Initialize an Array
  • Var
  • list array1..25 of Integer
  • i integer
  • Begin
  • i 1
  • while(i lt 100) do
  • Begin
  • listi 0 // oder listi i
  • i i 1
  • End
  • . . . //usw.

5
Matrix 2 Dimensional
  • A matrix is like a spreadsheet, rows and columns
  • myMatrix array 1..10, 1..5 of integer
  • myMatrix3, 5 25
  • myMatrix1,1 myMatrix1,1 2
Write a Comment
User Comments (0)
About PowerShow.com