Something like this could work. You need basic understanding of nested loops to be able to do this question.
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char const *argv[]) {
int rows, cols, i, j;
printf("Enter rows for box: ");
if (scanf("%d", &rows) != 1) {
printf("Invalid rows\n");
exit(EXIT_FAILURE);
}
printf("Enter columns for box: ");
if (scanf("%d", &cols) != 1) {
printf("Invalid columns\n");
exit(EXIT_FAILURE);
}
printf("\n2D Array Box:\n");
for (i = 1; i <= rows; i++) {
for (j = 1; j <= cols; j++) {
printf(" --- ");
}
printf("\n");
for (j = 1; j <= cols; j++) {
printf("| |");
}
printf("\n");
}
/* bottom "---" row */
for (i = 1; i <= cols; i++) {
printf(" --- ");
}
return 0;
}
solved Printing 2d array box