Fall 2001(c)opyright Brent M. Dingle 2001 Multidimensional Arrays Brent M. Dingle Texas A&M University Chapter 10 – Section 2, part B (and some from Mastering.

Slides:



Advertisements
Similar presentations
Click to edit Master title style. Click to edit Master subtitle style.
Advertisements

Daily Compounding pp SECTION. Click to edit Master text styles Second level Third level Fourth level Fifth level 2 SECTION Copyright © Glencoe/McGraw-Hill.
Kindergarten Math Fact Fluency Goal
State Income Tax pp SECTION. Click to edit Master text styles Second level Third level Fourth level Fifth level 2 SECTION Copyright © Glencoe/McGraw-Hill.
Term Life Insurance pp SECTION. Click to edit Master text styles Second level Third level Fourth level Fifth level 2 SECTION Copyright ©
Installment Loans― Allocation of Monthly Payment pp SECTION.
Fall 2001(c)opyright Brent M. Dingle 2001 Arrays Brent M. Dingle Texas A&M University Chapter 9 – Sections 1 and 2 (and some from Mastering Turbo Pascal.
Compound Interest pp SECTION. Click to edit Master text styles Second level Third level Fourth level Fifth level 2 SECTION Copyright © Glencoe/McGraw-Hill.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part D (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Monthly Payment and Total Interest pp SECTION.
Compound Interest Tables pp SECTION.
Simple Interest Installment Loans pp SECTION.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part B (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Top Down Design Brent M. Dingle Texas A&M University Chapter 4 – Section 1 (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Fall 2001(c)opyright Brent M. Dingle 2001 Simple Sorting Brent M. Dingle Texas A&M University Chapter 10 – Section 1 (and some from Mastering Turbo Pascal.
Writing Checks pp SECTION. Click to edit Master text styles Second level Third level Fourth level Fifth level 2 SECTION Copyright © Glencoe/McGraw-Hill.
Title of Presentation May Go Here Department Name Presentation for March 4, 2014 University Marketing.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part C (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Fall 2001(c)opyright Brent M. Dingle 2001 Abstract Data Types (ADTs) Brent M. Dingle Texas A&M University Chapter 8 – Sections 2 and 3 (and some from Mastering.
Headline sample style Intro sample style Click to edit Master text styles –Second level Third level –Fourth level o Fifth level.
Chapter 8 Section 3.
Section 1.2 Functions and Graphs.
Chapter 8 Multidimensional Arrays
CPSC Pascal Brent M. Dingle Texas A&M University Chapter 3
Chapter 7 Multidimensional Arrays
Chapter 8 Multidimensional Arrays
Brent M. Dingle Texas A&M University Chapter 6, Sections 1 and 2
Use the Binomial Theorem
Click to Add Title Click to Add Subtitle.
OBJECT ORIENTED PROGRAMMING II GEORGE KOUTSOGIANNAKIS
Use the Binomial Theorem
CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002
8.1 Sampling Distributions
Chapter 8 Multidimensional Arrays
(c)opyright Brent M. Dingle 2001
Click to edit Master text styles
Use the Binomial Theorem
Chapter 8 Multidimensional Arrays
Author names here Author association names here
Chapter 7 Multidimensional Arrays
Click to edit Master text styles
Chapter 8 Multidimensional Arrays
Chapter 8 Multidimensional Arrays
CMSC Discrete Structures
Turbo Pascal Units (TPU)
Multidimensional Arrays
Chapter 8 Multidimensional Arrays
Click to edit Master text styles
Procedures Brent M. Dingle Texas A&M University
Slide Title Edit Master text styles Second level Third level
ОПШТЕСТВО ТЕМА: МЕСТОТО ВО КОЕ ЖИВЕАМ Скопје
Multidimensional Arrays
Multidimensional array
Author names here Author associations here
Author names here Author associations here
Chapter 8 Multidimensional Arrays
Chapter 7 Multidimensional Arrays
Click to edit Master text styles
Lorem ipsum dolores Lorem ipsum dolores.
(c)opyright Brent M. Dingle 2001
Brent M. Dingle Texas A&M University Chapter 5 – Section 2-3
Chapter 7 Multidimensional Arrays
Author names here Author associations here
Chapter 7 Multidimensional Arrays
Complex Array Structures
Click to edit Master text styles
Brent M. Dingle Texas A&M University Chapter 5 – Section 1
Click to edit Master title style
Chapter 8 Multidimensional Arrays
Presentation transcript:

Fall 2001(c)opyright Brent M. Dingle 2001 Multidimensional Arrays Brent M. Dingle Texas A&M University Chapter 10 – Section 2, part B (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)

Fall 2001(c)opyright Brent M. Dingle 2001 Multi-Dim but no enumerated So what if we want to make an array of things that are just stored in a grid indexed by numbers. None of this fancy enumerated indexing?

Fall 2001(c)opyright Brent M. Dingle 2001 For example back to Grades What if we wanted to store multiple grades for many students. For example we have 10 students, each with five grades. How could we use arrays to do that?

Fall 2001(c)opyright Brent M. Dingle 2001 Recall If we just had 10 students, each with one grade we would just say: TYPE GRADE_ARY = array[1..10] of real; VAR grade : GRADE_ARY; And then  student number 1’s grade would be stored in grade[1]  student number 2’s grade would be stored in grade[2]  student number 3’s grade would be stored in grade[3]  and so on up to  student number 10’s grade would be stored in grade[10]

Fall 2001(c)opyright Brent M. Dingle 2001 So giving each student 5 grades requires a 2-d array 2-d stands for 2 dimensional (i.e. we use 2 indices to access it) To create this type of array we say: TYPE GRADES_2D_ARY = array[1..10, 1..5] of real; VAR stud_grade : GRADES_2D_ARY;

Fall 2001(c)opyright Brent M. Dingle 2001 Then to access the grades To access the grades we would have the first index correspond to the student number And the second index correspond to the grade number.

Fall 2001(c)opyright Brent M. Dingle 2001 Accessing grades (cont 1) So to access student number 1’s FIRST grade we would use stud_grade[1, 1] So to access student number 1’s SECOND grade we would use stud_grade[1, 2] So to access student number 1’s THIRD grade we would use stud_grade[1, 3] So to access student number 1’s FOURTH grade we would use stud_grade[1, 4] So to access student number 1’s FIFTH grade we would use stud_grade[1, 5]

Fall 2001(c)opyright Brent M. Dingle 2001 Accessing grades (cont 2) So to access student number 2’s FIRST grade we would use stud_grade[2, 1] So to access student number 2’s SECOND grade we would use stud_grade[2, 2] So to access student number 2’s THIRD grade we would use stud_grade[2, 3] So to access student number 2’s FOURTH grade we would use stud_grade[2, 4] So to access student number 2’s FIFTH grade we would use stud_grade[2, 5]

Fall 2001(c)opyright Brent M. Dingle 2001 Accessing grades (cont 3) Any guesses on how we access the FOURTH grade of student number 3? [pause] If you said stud_grade[3, 4] You would be right ! =)

Fall 2001(c)opyright Brent M. Dingle 2001 The table for the above 2-d array is as follows:

Fall 2001(c)opyright Brent M. Dingle 2001 Some work Using the table on the previous slide, What is the value of: stud_grade[1, 1] stud_grade[2, 1] stud_grade[4, 5] stud_grade[9, 3] stud_grade[6, 2]

Fall 2001(c)opyright Brent M. Dingle 2001 Some work (cont) Give up? stud_grade[1, 1] = 54 stud_grade[2, 1] = 78 stud_grade[4, 5] = 89 stud_grade[9, 3] = 75 stud_grade[6, 2] = 78

Fall 2001(c)opyright Brent M. Dingle 2001 Notation As an aside, notice Pascal will allow us to access the members of a 2-d array in two ways: stud_grade[2, 4] is the same as stud_grade[2][4]. For the most part use the first way (stud_grade[2, 4]) if you are using a 2-d array and the second way (stud_grade[2][4]) if you are using an array of arrays.

Fall 2001(c)opyright Brent M. Dingle 2001 Suggested Problems (no grade) page 398 4, 5, 6, 7 pages 401 – 405 (programming exercises) 8, 10, 13, 15 ***, 16, 19, 21

Fall 2001(c)opyright Brent M. Dingle 2001 End Multidimensional Arrays Thus ends Chapter 10