Write a C program to print inverted right triangle alphabets pattern using for loop.
#include <stdio.h> int main() { int rows; printf("Enter Inverted Right Triangle of Alphabets Rows = "); scanf("%d", &rows); printf("Printing Inverted Right Triangle Alphabets Pattern\n"); int alphabet = 65; for (int i = rows - 1; i >= 0; i--) { for (int j = 0; j <= i; j++) { printf("%c ", alphabet + j); } printf("\n"); } }
This C example prints the inverted right triangle pattern of alphabets using a while loop.
#include <stdio.h> int main() { int rows, i, j, alphabet; printf("Enter Inverted Right Triangle of Alphabets Rows = "); scanf("%d", &rows); printf("Printing Inverted Right Triangle Alphabets Pattern\n"); alphabet = 65; i = rows - 1; while (i >= 0) { j = 0; while (j <= i) { printf("%c ", alphabet + j); j++; } printf("\n"); i--; } }
Enter Inverted Right Triangle of Alphabets Rows = 13
Printing Inverted Right Triangle Alphabets Pattern
A B C D E F G H I J K L M
A B C D E F G H I J K L
A B C D E F G H I J K
A B C D E F G H I J
A B C D E F G H I
A B C D E F G H
A B C D E F G
A B C D E F
A B C D E
A B C D
A B C
A B
A
In this C pattern example, we used the do while loop to display the right triangle of alphabets.
#include <stdio.h> int main() { int rows, i, j, alphabet; printf("Enter Inverted Right Triangle of Alphabets Rows = "); scanf("%d", &rows); printf("Printing Inverted Right Triangle Alphabets Pattern\n"); alphabet = 65; i = rows - 1; do { j = 0; do { printf("%c ", alphabet + j); } while (++j <= i); printf("\n"); } while (--i >= 0); }
Enter Inverted Right Triangle of Alphabets Rows = 15
Printing Inverted Right Triangle Alphabets Pattern
A B C D E F G H I J K L M N O
A B C D E F G H I J K L M N
A B C D E F G H I J K L M
A B C D E F G H I J K L
A B C D E F G H I J K
A B C D E F G H I J
A B C D E F G H I
A B C D E F G H
A B C D E F G
A B C D E F
A B C D E
A B C D
A B C
A B
A