Write a C program to print left arrow numbers pattern using for loop.
#include <stdio.h> int main() { int rows, i, j; printf("Enter Left Arrow Number Pattern Rows = "); scanf("%d", &rows); printf("Printing Left Arrow Numbers Pattern\n"); for (i = rows; i >= 1; i--) { for (j = i; j >= 1; j--) { printf("%d ", j); } printf("\n"); } for (i = 2; i <= rows; i++) { for (j = i; j >= 1; j--) { printf("%d ", j); } printf("\n"); } }
This C example prints the left arrow of the pattern of the numbers using a while loop.
#include <stdio.h> int main() { int rows, i, j; printf("Enter Left Arrow Number Pattern Rows = "); scanf("%d", &rows); printf("Printing Left Arrow Numbers Pattern\n"); i = rows; while (i >= 1) { j = i; while (j >= 1) { printf("%d ", j); j--; } printf("\n"); i--; } i = 2; while (i <= rows) { j = i; while (j >= 1) { printf("%d ", j); j--; } printf("\n"); i++; } }
Enter Left Arrow Number Pattern Rows = 11
Printing Left Arrow Numbers Pattern
11 10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
7 6 5 4 3 2 1
6 5 4 3 2 1
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
11 10 9 8 7 6 5 4 3 2 1
This C example uses the do while loop to print the left arrow pattern of numbers.
#include <stdio.h> int main() { int rows, i, j; printf("Enter Left Arrow Number Pattern Rows = "); scanf("%d", &rows); printf("Printing Left Arrow Numbers Pattern\n"); i = rows; do { j = i; do { printf("%d ", j); } while (--j >= 1); printf("\n"); } while (--i >= 1); i = 2; do { j = i; do { printf("%d ", j); } while (--j >= 1); printf("\n"); } while (++i <= rows); }
Enter Left Arrow Number Pattern Rows = 13
Printing Left Arrow Numbers Pattern
13 12 11 10 9 8 7 6 5 4 3 2 1
12 11 10 9 8 7 6 5 4 3 2 1
11 10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
7 6 5 4 3 2 1
6 5 4 3 2 1
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
11 10 9 8 7 6 5 4 3 2 1
12 11 10 9 8 7 6 5 4 3 2 1
13 12 11 10 9 8 7 6 5 4 3 2 1