20.1D_Array - Arrays Data Types Data types are of two...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Arrays Data Types Data types are of two kinds: - simple data types (e.g. int, float, double, char) - Structured data type: (e.g. arrays) An array is a collection of two or more adjacent memory cells, called array elements, that are associated with a particular symbolic name. Arrays are of two kinds: - Arrays of one-dimension - Arrays of two-dimension
Background image of page 1

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

View Full DocumentRight Arrow Icon
One-Dimensional Arrays Declaration of one-dimension array Syntax : atype aname [ size ] ; // uninitialized array atype aname [ size ] = { initialization list } ; where atype is any data type; aname is the name given to the array; size represents the number of elements in the array. initialization list is the list of initial values given to the array.
Background image of page 2
One-Dimensional Arrays Examples EX1: int x [ 3 ]; - This tells the compiler to associate 3 memory cells with name x. - These cells will be adjacent to each other in memory. - Each element of array x contains a value of integer type EX2 : int Y [ 4 ] = { 2, 4, 6, 8 } ; This initializes array Y to have 4 elements which contain 2, 4, 6, 8.
Background image of page 3

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

View Full DocumentRight Arrow Icon
24 20 10 Accessing One-Dimensional Array int x [3] ; Array x in memory: How to process the data stored in an array? Syntax:
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

20.1D_Array - Arrays Data Types Data types are of two...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online