{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lec c7 - More than one Dimension Two dimensional arrays...

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

More than one Dimension Two dimensional arrays also called as matrix Declaration: type variable_name[row_size][column_size]; row_size –>Number of rows in matrix column_size –> Number of columns in matrix Examples: int number[4][3]; /* 12 elements */ float number[3][2]; /* 6 elements */ char name[10][20]; /* 200 chars */

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

View Full Document
Initialization of a 2-D Array int a[2][3]={1,2,3,4,5,6}; int a[2][3]={{1,2,3}, {4,5,6}}; int a[][3]={{1,2,3}, {4,5,6}} int a[2][3]={0} How values will be assigned in each case?? Following initializations are not allowed int a[3][]={2,4,6,8,10,12}; int a[][]={2,4,6,8,10,12}; Note: If the first bracket pair is empty, then compiler takes the size from the number of inner brace pairs
Initialization of a 2-D Array The following fragment of code initializes the array (arr[rows][columns])at runtime: for (i=0;i<rows;i++) for (j=0;j<columns;j++) scanf (“%d”,&arr[i][j]); Q. Can we interchange “rows” and “columns” in the above code fragment ???

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

View Full Document
Memory Map for 2-D Arrays Kept in memory as a linear sequence of variables .
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

Lec c7 - More than one Dimension Two dimensional arrays...

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

View Full Document
Ask a homework question - tutors are online