Chapter 7 - Arrays
Chapter 7 - Arrays
Mhammed Chraibi
outline
• What are arrays?
• Why we need arrays?
• How useful are arrays?
• Implementing arrays
• Multi-dimensional arrays
• Review and applications
Introduction
• Arrays are a composite data structure
(composed of many items of same data-type)
• Selection Sort
http://www.youtube.com/watch?v=6nDMgr0-Yy
o
using array elements as function args
• scanf(“%lf” , &double_arr[2]);
• Stack of Plates
• Queue of people
Multi-dimensional array
• Those are arrays with 2 or more dimensions
• 2-dimentional arrays are used to represent
tables of data, matrices, etc…
• The way we allocate memory for a two-
dimensional array is the following:
• int arr[6][3];