
2-D Arrays
Dynamically 2-D Array Allocation
int **arr = new int*[rows];
for (int i = 0; i < rows; i++){
arr[i] = new int[cols];
}
// releasing memory
for (int i = 0; i < rows; i++){
delete [] arr[i];
}
delete []arr;int arr[][3] = { { 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 } };
int total_Elements = sizeof(arr)/sizeof(int); // 36 / 4 = 9
cout << "Total Number of elements are: " << total_Elements << endl;
int rows = sizeof(arr)/sizeof(arr[0]); // 36 / 12 = 3
int cols = sizeof(arr[0])/sizeof(int); // 12 / 4 = 3
cout << "No of Rows are: " << rows << endl;
cout << "No of Columns are: "<< cols << endl;
Q1: Row-Wise Sum
Q1: Row-Wise Sum Q2: Column-Wise Sum
Q2: Column-Wise Sum Q4: Spiral Matrix
Q4: Spiral MatrixQ5: Transpose of a Matrix
Q5: Transpose of a MatrixQ6: Rotate Image
Q6: Rotate ImageQ7: Jagged Array
Q7: Jagged ArrayQ8: Addition of 2 Matrix
Q8: Addition of 2 MatrixQ9: Multiplication of a matrix
Q9: Multiplication of a matrixQ10: Reverse 2d array
Q10: Reverse 2d array Q11: Spiral Matrix II
Q11: Spiral Matrix IIQ12: Spiral Matrix IV
Q12: Spiral Matrix IVLast updated
Was this helpful?