#include <stdio.h>
#include <stdlib.h>
int main() {
int rows = 3, cols = 4;
int i, j;
int **p = (int **)malloc(rows * sizeof(int *)); // allocate memory for rows
// allocate memory for columns
for (i = 0; i < rows; i++) {
p[i] = (int *)malloc(cols * sizeof(int));
}
// initialize array
for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++) {
p[i][j] = i * j;
}
}
// print array
for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++) {
printf("%d ", p[i][j]);
}
printf("\n");
}
// free memory
for (i = 0; i < rows; i++) {
free(p[i]);
}
free(p);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: