#include <stdio.h> int main() { int rows, cols, i, j; /* Input rows and columns from user */ printf("Enter number of rows: "); scanf("%d", &rows); printf("Enter number of columns: "); scanf("%d", &cols); for(i=1; i<=rows; i++) { for(j=1; j<=cols; j++) { /* * Print 1 if its first or last row * Print 1 if its first or last column */ if(i==1 || i==rows || j==1 || j==cols) { printf("1"); } else { printf("0"); } } printf("\n"); } return 0; }
0 Comments
If you have any doubts, Please let me know