Posts

unknown Facts to know about 2D array

Image
Two Dimensional Array Many time we come up with the idea to create our program by using 2-D array. There are so many ways to declare the two dimensional array, some of them are here below. So without Any further delay lets start to decode this problem: 1)      This is the most common type of declaration of the 2-D array when we come up with the default size od the 2D array:      int array[10][5]; 2)     Dynamically allocating a two-dimensional array is a little more challenging. You may be tempted to try something like this: int **array = new int[10][5]; // ⚠ won’t work! But it won’t work. Now, you guys must be confused that how is this possible. Why do the compiler behaves like that. The simple answer is whenever you declare the 2d array the first thing that compiler have to know is that the size of the array i.e the coloumn size so that it can give space for the upcoming data. So for that you have to declare the coloumn size as a constant. It must be a c