Giáo trình tin học chương IV
1 Chapter - Arrays Outline 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 Introduction Arrays Declaring Arrays Examples Using Arrays Passing Arrays to Functions Sorting Arrays Searching Arrays: Linear Search and Binary Search Multiple-Subscripted Arrays 2003 Prentice Hall, Inc All rights reserved Arrays • Array – – – – Structures of related data items Static entity (same size throughout program) Consecutive group of memory locations Same name and type (int, char, etc.) • To refer to an element – Specify array name and position number (index) – Format: arrayname[ position number ] – First element at position • N-element array c c[ ], c[ ] … c[ n - ] – Nth element as position N-1 2003 Prentice Hall, Inc All rights reserved Arrays • Array elements like other variables – Assignment, printing for an integer array c c[ ] = 3; cout