# How to find a largest size of 2D arrays in C language?

*label*Computer Science

*timer*Asked: Apr 5th, 2015

**Question description**

This is the homework question:

By trial and error, discover what the largest value of **x** can be in the following program so that it still compiles and runs without error:main(){

int array[**x**][**x**];

array[0][0] = 0;

}

Print this value of x at the start of your submission. Then use malloc to create a 5000 by 5000 square array. Fill this array with random numbers in the range [0, 6]. Iterate through the array again, counting the number of times each value appeared.

Sample session (note: for the purpose of this sample, the value of x is incorrect. You should discover this value on your own.)

> **./a.out**

x = 12

there are 3570129 0s

there are 3570751 1s

there are 3571904 2s

there are 3573195 3s

there are 3571223 4s

there are 3568653 5s

there are 3574145 6s