# lec17 - Lecture 17 Arrays(Savitch 6.1 CS125 Course Notes...

This preview shows pages 1–6. Sign up to view the full content.

CS125 Course Notes Lecture 17, Slide 1 Lecture 17 •Arrays (Savitch 6.1)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS125 Course Notes Lecture 17, Slide 2 Motivating arrays • You have a list of your friends’ birthdays and want to determine how many were born in September. • Later in the program, you need to determine how many were born in a different month.
CS125 Course Notes Lecture 17, Slide 3 First approach Set septCounter to 0 for each friend { get friend’s birth date; if birthday is in September update septCount; } Any problems?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS125 Course Notes Lecture 17, Slide 4 Second approach Assume 4 friends. Initialize variables friend1, friend2, friend3, friend4 to birth dates; Set septCounter to 0 if friend1 born in September update count; if friend2 born in September update count; if friend3 born in September update count; if friend4 born in September update count; Any problems?
Course Notes Lecture 17, Slide 5 Arrays • A special kind of structure that stores a collection of variables. • All variables are of the same type. • The number of entries is fixed when the array is created. • Individual elements can be accessed

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/27/2009 for the course MATH 135 taught by Professor Andrewchilds during the Fall '08 term at Waterloo.

### Page1 / 22

lec17 - Lecture 17 Arrays(Savitch 6.1 CS125 Course Notes...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online