cp_1_lect_36 - Two-Dimensional Arrays month year Obj100...

Info iconThis preview shows pages 1–4. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Two-Dimensional Arrays month year Obj100 Average Yearly Rainfall (in mm) int table [5][12] = { {30,40,75,95,130,220,210,185,135,80,40,45}, {25,25,80,75,115,270,200,165, 85, 5,10, 16}, {35,45,90,80,100,205,135,140,170,75,60,95}, {30,40,70,70, 90,180,180,210,145,35,85,80}, {30,35,40,90,150,230,305,295, 60,95,80,30} }; 5/10/10 int table [5][12]; int table [5][12] = {30,40,75, ... ,80,30}; OR Two-Dimensional Array Initialization continued... int table [ ][12] = { {30,40,75,95,130,220,210,185,135,80,40,45}, {25,25,80,75,115,270,200,165, 85, 5,10, 16}, {35,45,90,80,100,205,135,140,170,75,60,95}, {30,40,70,70, 90,180,180,210,145,35,85,80}, {30,35,40,90,150,230,305,295, 60,95,80,30} }; Need not specify the size of the first dimension when the array is completely initialized If the values are missing in an initializer, they are automatically set to zero int a[3][ ] = {2,4,6,8,10,12}; int a[ ][ ] = {2,4,6,8,10,12}; 5/10/10 Not allowed Memory layout int table[4][3]={{2,5,6},{9,3,5},{1,7,2},{ 3,0,5}}; 0 0 1 2 er rd Row1 1 ow R m r jo a o 2 3 Row3 2 5 6 9 3 5 1 7 2 3 0 5 Row0 Row2 Accessing Two Dimensional Arrays int a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12 }; for (i = 0; i < 3; i++) { for ( j = 0; j < 4; j++) { 5/10/10 Output 1 2 3 4 5 6 7 8 9 10 11 12 ...
View Full Document

This note was uploaded on 05/07/2010 for the course CS&IS TA C162 taught by Professor Kavitha during the Spring '09 term at Birla Institute of Technology & Science.

Page1 / 4

cp_1_lect_36 - Two-Dimensional Arrays month year Obj100...

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

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