> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/c/create_a_two-dimensional_array_at_runtime.md).

# Create a two-dimensional array at runtime

```ruby
func make_matrix(x, y) {
    y.of { x.of(0) }
}
 
var y = read("rows: ", Number)
var x = read("cols: ", Number)
 
var matrix = make_matrix(x, y)    # create the matrix
matrix[y/2][x/2] = 1              # write something inside it
say matrix                        # display the matrix
```

#### Output:

```
rows: 3
cols: 4
[[0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]
```
