introC_lec12

introC_lec12 - 10/7/2010 Computer Programming for...

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

View Full Document Right Arrow Icon
10/7/2010 1 Computer Programming for Engineering Applications ECE 175 Intro to Programming 10/7/2010 1 ECE 175, Fal 2010 Declaration of arrays with more than one dimension Accessing arrays with multiple dimensions Multi-dimensional Arrays 10/7/2010 ECE 175, Fal 2010 2 Syntax: data type array_name[size][size] Example: int two_dimensions[5][7]; double many_dimensions[10][20][30][50] Example: int two_dimensions[5][7]; x = two_dimensions[1][4]; y = two_dimensions[2][4] + two_dimensions[3][1]; Subscripts of Two Dimensional Arrays 10/7/2010 ECE 175, Fal 2010 3 1 5 6 7 9 6 8 1 2 3 5 3 1 2 5 2 2 5 5 4 6 7 6 4 1 8 8 7 3 2 4 4 1 6 3 i: 0 1 2 3 4 j: 0 1 2 3 4 5 6 Example: int two_dimensions[5][7]; x = two_dimensions[1][4]; // x = ? y = two_dimensions[2][4] + two_dimensions[0][1]; // y = ? Nested for loops Declare two indexes that would run through the size of each dimension Write two for nested for loops Initializing arrays with more than one dimension 10/7/2010 ECE 175, Fal 2010 4 Example: int two_dimensions[5][7];
Background image of page 1

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

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

Page1 / 3

introC_lec12 - 10/7/2010 Computer Programming for...

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

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