X hits on this document

220 views

0 shares

0 downloads

0 comments

14 / 63

Copyright ©2004 Pearson Addison-Wesley. All rights reserved.

8-14

Access (1)

1.

point[1]          // the 2nd element of array point is accessed

2.

point[9] = 20; // the 10th  element of array point is assigned          // the value 20

3.

Want to process all of the elements of an array?

Example: Adding the values of all array elements

Two alternative style for loops

for ( i = 0; i < arraySize; i++)  sum += a[i];

for ( i = 0; i <= arraySize-1; i++)  sum += a[i];

Note : The array element is a single valued variable of the corresponding type and can be manipulated as a variable of that type.

Document info
Document views220
Page views220
Page last viewedSun Jan 22 10:17:12 UTC 2017
Pages63
Paragraphs754
Words4119

Comments