sachin
answered Apr 26 '23 00:00
In many programming languages, you can declare a two-dimensional array by specifying the number of rows and columns. Here are some examples in different programming languages:
Java
int[][] array = new int[3][4]; // creates a 3x4 array of integers
C++
int array[3][4]; // creates a 3x4 array of integers
Python
array = [[0 for i in range(4)] for j in range(3)]
JavaScript
let array = new Array(3);
for (let i = 0; i < array.length; i++) {
array[i] = new Array(4);
}
In general, you can create a two-dimensional array by creating an array of arrays. The outer array represents the rows and the inner arrays represent the columns. You can then access elements of the array using two indices, one for the row and one for the column.