Write a C program to Print Number Pattern 7 with example. For this reverse numbered right triangle, we are going to use For Loop and While Loop.
C program to Print Number Pattern 7 using For Loop
This program allows the user to enter the maximum number of rows he/she want to print as a right angled triangle. Next, compiler will print the numbers from maximum to minimum in right triangle pattern.
/* C program to Print Number Pattern 7 */ #include<stdio.h> int main() { int i, j, rows; printf(" \nPlease Enter the Number of Rows : "); scanf("%d", &rows); for(i = rows; i >= 1; i--) { for(j = rows; j >= i; j--) { printf(" %d", i); } printf("\n"); } return 0; }

Program to Print Number Pattern 7 using while Loop
In this program we just replaced the For Loop with the While Loop. I suggest you to refer While Loop article to understand the C Programming logic.
/* C program to Print Number Pattern 7 */ #include<stdio.h> int main() { int i, j, rows; printf(" \nPlease Enter the Number of Rows : "); scanf("%d", &rows); i = rows; while( i >= 1) { j = rows; while( j >= i) { printf("%d", i); j--; } i--; printf("\n"); } return 0; }
Please Enter the Number of Rows : 9
9
88
777
6666
55555
444444
3333333
22222222
111111111