Intoxyy
0
Q:

2d array declaration different method in c

// Either
int disp[2][4] = {
  {10, 11, 12, 13},
  {14, 15, 16, 17}
};

// Or 
int disp[2][4] = { 10, 11, 12, 13, 14, 15, 16, 17};

// OR
int i, j;
for (i = 0; i < HEIGHT; i++) { // iterate through rows
  for (j = 0; j < WIDTH; j++) { // iterate through columns
    disp[i][j] = disp[i][j];
  }
}
3
int disp[2][4] = { 10, 11, 12, 13, 14, 15, 16, 17};
3
// Different ways to initialize two-dimensional array

int c[2][3] = {{1, 3, 0}, {-1, 5, 9}};
         
int c[][3] = {{1, 3, 0}, {-1, 5, 9}};
                
int c[2][3] = {1, 3, 0, -1, 5, 9};
0

New to Communities?

Join the community