class_notes9

class_notes9 - I Love Arrays Someday youll learn to love...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: I Love Arrays Someday youll learn to love them too What is an array? | An array is a group of memory locations with the same name and same type | Arrays contain multiple elements of the same data type ( int, char, float, double ) | Arrays DO NOT mix different types of data | Structures can mix types, but youll learn about those in later courses Array Indexing | Elements of an array are referred to by their subscript or index | This index is contained in the brackets after the array name | In C, the first element of an array has an index of 0, the second has index of 1, etc. 53 c[0] 2 c[1]-35 c[2] 1024 c[3] c[4] 1 c[5]-562 c[6]-3 c[7] 1024 c[8] Array Indexing | WARNING! z An n-element array will only have an index up to n-1 z This is a common source of errors 53 c[0] 2 c[1]-35 c[2] 1024 c[3] c[4] 1 c[5]-562 c[6]-3 c[7] 1024 c[8] Array Indexing | Expressions can be used to evaluate the index z Example: if a = 2 , and b = 3 , then c[a+b] += 2; is perfectly valid | Other okay expressions: z printf(%d, c[0]+c[1]); z x = c[5] / 2; Defining Arrays...
View Full Document

This note was uploaded on 08/06/2010 for the course ENGR 3 taught by Professor Ben-yaakov during the Summer '08 term at UCSB.

Page1 / 12

class_notes9 - I Love Arrays Someday youll learn to love...

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

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