C Program to print zero border rectangular pyramid
C Program to print zero border rectangular pyramid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<stdio.h> int main() { int number, row, col; printf("\nEnter Number of Rows to be display : \n"); scanf("%d", &number); for (row = 1; row <= number; row++) { for (col = 1; col <= number; col++) { if (row == 1 || row == number) { printf("0\t"); } else if (col == 1 || col == number) { printf("0\t"); } else { printf("1\t"); } } printf("\n"); } return 0; } |
Output :
1 2 3 4 5 6 7 | Enter Number of Rows to be display : 6 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 |