#include <stdio.h>
#include <stdlib.h>
int main() {
// Dynamic 2D array allocation
int rows, cols;
printf("Enter the number of rows: ");
scanf("%d", &rows);
printf("Enter the number of columns: ");
scanf("%d", &cols);
int **dynamic2DArray = (int **)malloc(rows * sizeof(int *));
for (int i = 0; i < rows; i++) {
dynamic2DArray[i] = (int *)malloc(cols * sizeof(int));
}
// Use the dynamically allocated 2D array
// Free the allocated memory
for (int i = 0; i < rows; i++) {
free(dynamic2DArray[i]);
}
free(dynamic2DArray);
return 0;
}