Download presentation
Presentation is loading. Please wait.
Published bySara Cummings Modified over 6 years ago
1
Lecture 25 The Tao that can be talked about is not the true Tao
Opening line of Tao Te Ching
2
Arrays Remember strings. They are collections of characters which are stored in memory sequentially. We want to be able to have a sequence of variables of any type. There are many applications when this would be helpful.
3
Arrays Pascal offers arrays to address this problem. Array is simply a sequence of variables of some type addressable via index. For example: TYPE IntegerArray = ARRAY[1..5] of integer; Size or range Type name Basic type of element Type keyword Array keyword
4
Arrays TYPE IntegerArray = ARRAY[1..5] of integer;
You can now do this: VAR aMyArray : IntgerArray; That is, you can now have a variable of this type! What does this new variable look like in memory? aMyArray[ 1 ] aMyArray[ 2 ] aMyArray[ 3 ] ...
5
Arrays You can have arrays of any basic types
TYPE CharArray = ARRAY[1..10] of char; TYPE BoolArray = ARRAY[1..100] of boolean; TYPE RealArray = ARRAY[1..7] of real; TYPE NegIntArray = ARRAY[ ] of boolean; TYPE WhatIsThis = ARRAY[‘a’..’z’] of integer;
6
Numbers in reverse Write a program which reads in integers into an array and then prints them in reverse.
7
Grades histogram
8
Letter frequency Write a program which reads in several English sentences and displays letter frequency histogram
9
Home work Read 10.1,10.2 Hw #7 due Monday, December 14th (ABSOLUTE DEADLINE) Optional problems: page 473 #1, 2, 6, 13, 15 Look at last year’s final Start reviewing
10
Programs from this lecture
Numbers in reverse Grade histogram1 Grade histogram2 Letter frequency
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.