Arrays - University of Iowa

1

7

Arrays

? 2005 Pearson Education, Inc. All rights reserved.

2

7.1 Introduction

? Arrays

? Data structures ? Related data items of same type ? Remain same size once created

? Fixed-length entries

? 2005 Pearson Education, Inc. All rights reserved.

3

7.2 Arrays

? Array

? Group of variables

? Have same type

? Reference type

? 2005 Pearson Education, Inc. All rights reserved.

4

Fig. 7.1 | A 12-element array.

? 2005 Pearson Education, Inc. All rights reserved.

5

7.2 Arrays (Cont.)

? Index

? Also called subscript ? Position number in square brackets ? Must be positive integer or integer expression ? First element has index zero

a = 5; b = 6; c[ a + b ] += 2;

? Adds 2 to c[ 11 ]

? 2005 Pearson Education, Inc. All rights reserved.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download