2d array in kotlin

// Step 1: Declare a 2D array
val rows = 3
val columns = 4
val twoDArray = Array(rows) { IntArray(columns) }

// Step 2: Initialize the 2D array
for (i in 0 until rows) {
    for (j in 0 until columns) {
        twoDArray[i][j] = i * columns + j
    }
}

// Step 3: Access elements in the 2D array
val element = twoDArray[1][2]

// Step 4: Print the 2D array
for (row in twoDArray) {
    for (value in row) {
        print("$value ")
    }
    println()
}