9-Arrays

# 9-Arrays - Arrays MIDTERM Monday Oct 17 In class Multiple...

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

Arrays

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

View Full Document
MIDTERM Monday Oct 17 In class Multiple Choice Short answer program questions Closed book, no computers, OR PHONES Four exam versions
Reading Chapter 4, pgs 109 -114

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

View Full Document
“Lists” of Variables Sometimes, it becomes necessary to order variables in a list: Temperature on April 1 = 90 Temperature on April 2 = 87 Temperature on April 3 = 84 in order to spot trends.
Lists of variables All of the variables and values are of the same type – integers, strings, whatever. Their order is important. Their place in the list is important May be shortened as… Temp1 = 90 Temp2 = 87 Temp3 = 84

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

View Full Document
Track the order as a separate variable Called an “index”: Temp[1] = 90 Temp[2] = 87 Temp[3] = 84 x = 2 Temp[ x ] = ? Name [ index ] = value…. index can change!
Arrays A difficult concept at first : int z[5]; Means: z[0], z[1] , z[2], z[3], z[4] are separate integer variables Starts at 0. An array with 5 elements is indexed (or subscripted ) from 0 to 4. in C++: int z[ 5 ];

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

View Full Document
int x; int z[ 10 ]; for (x = 0; x <= 9; x = x+1) { z[x] = x; } What is the value of z[4]? 4! in fact…
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 11/03/2011 for the course EAS 230 at SUNY Buffalo.

### Page1 / 25

9-Arrays - Arrays MIDTERM Monday Oct 17 In class Multiple...

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

View Full Document
Ask a homework question - tutors are online