We want to dynamically allocate a two dimensional int array

We want to dynamically allocate a two dimensional int array named t with two rows and three columns. Write statements to accomplish this. First declare t with appropriate type, then use dynamic allocation more than once to create the entire array.

Solution


// Create a dynamic array of pointers of two
int **t = new int*[2];

// Create two rows for every pointer
   t[0] = new int[3];
   t[1] = new int[3];

 We want to dynamically allocate a two dimensional int array named t with two rows and three columns. Write statements to accomplish this. First declare t with

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site