Write a C program to print right triangle of alphabets in reverse pattern using for loop.
#include <stdio.h> int main() { int rows; printf("Enter Right Triangle Reverse Characters Rows = "); scanf("%d", &rows); printf("Right Triangle of Characters in Reverse Pattern\n"); int alphabet = 65; for (int i = rows - 1; i >= 0; i--) { for (int j = rows - 1; j >= i; j--) { printf("%c ", alphabet + j); } printf("\n"); } }
This pattern example uses a while loop to print the right angled triangle of alphabets in reverse or descending order.
#include <stdio.h> int main() { int i, j, alphabet, rows; printf("Enter Right Triangle Reverse Characters Rows = "); scanf("%d", &rows); printf("Right Triangle of Characters in Reverse Pattern\n"); alphabet = 65; i = rows - 1; while (i >= 0) { j = rows - 1; while (j >= i) { printf("%c ", alphabet + j); j--; } printf("\n"); i--; } }
Enter Right Triangle Reverse Characters Rows = 17
Right Triangle of Characters in Reverse Pattern
Q
Q P
Q P O
Q P O N
Q P O N M
Q P O N M L
Q P O N M L K
Q P O N M L K J
Q P O N M L K J I
Q P O N M L K J I H
Q P O N M L K J I H G
Q P O N M L K J I H G F
Q P O N M L K J I H G F E
Q P O N M L K J I H G F E D
Q P O N M L K J I H G F E D C
Q P O N M L K J I H G F E D C B
Q P O N M L K J I H G F E D C B A
This C program uses the do while loop to print the right angled triangle pattern of alphabets in reverse order.
#include <stdio.h> int main() { int i, j, alphabet, rows; printf("Enter Right Triangle Reverse Characters Rows = "); scanf("%d", &rows); printf("Right Triangle of Characters in Reverse Pattern\n"); alphabet = 65; i = rows - 1; do { j = rows - 1; do { printf("%c ", alphabet + j); } while (--j >= i); printf("\n"); } while (--i >= 0); }
Enter Right Triangle Reverse Characters Rows = 14
Right Triangle of Characters in Reverse Pattern
N
N M
N M L
N M L K
N M L K J
N M L K J I
N M L K J I H
N M L K J I H G
N M L K J I H G F
N M L K J I H G F E
N M L K J I H G F E D
N M L K J I H G F E D C
N M L K J I H G F E D C B
N M L K J I H G F E D C B A