Answers for "declare a 2d array"

C
8

2d array

int a[2][3]= {
        {1, 2, 3},
        {4, 5, 6}
    };
    
    cout << a[1][1]; // Output is 5
Posted by: Guest on May-27-2021
5

c fill 2d array

// 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];
  }
}
Posted by: Guest on February-27-2020

Code answers related to "C"

Browse Popular Code Answers by Language