Reverse Alphabet Decreasing Triangle in C++

What You’ll Learn
Print a triangle whose first row is the full reverse run from E to A, then each row drops the leftmost letter: EDCBA, DCBA, CBA, BA, A.
Pair this with program 6 (ABCDE, BCDE, … ending at E). Here both the outer start letter and the inner print direction move toward A.
⭐ Pattern Output
For five rows from 'E' down to 'A':
EDCBA
DCBA
CBA
BA
AComplete C++ Program
Outer i from 69 ('E') down to 65 ('A'); inner j from i down to 65, printing (char) j.
#include <iostream>
using namespace std;
int main() {
int i, j;
for (i = 69; i >= 65; i--) {
for (j = i; j >= 65; j--)
cout << (char) j;
cout << "\n";
}
return 0;
}🧠 How It Works
Headers and namespace
#include <iostream> and using namespace std; enable cout.
Outer loop: high letter
for (i = 69; i >= 65; i--) sets the first character on each row: E, D, C, B, A.
Inner loop: down to A
for (j = i; j >= 65; j--) prints from the row start down to 'A' with cout << (char) j.
Row length
Row starting at code i prints i - 65 + 1 characters: 5, 4, 3, 2, 1.
Fifteen letters total
For n = 5 rows: 5+4+3+2+1 = 15 — O(n²) in general.
Variation — User Input Version
high = 65 + rows - 1 is the first row’s leftmost letter (e.g. 68 = D for four rows). Loop i from high down to 65:
#include <iostream>
using namespace std;
int main() {
int rows;
int i, j;
const int base = 65;
cout << "Enter the number of rows: ";
cin >> rows;
int high = base + rows - 1;
for (i = high; i >= base; i--) {
for (j = i; j >= base; j--)
cout << (char) j;
cout << "\n";
}
return 0;
}💡 Tips for Enhancement
Try These
- Prefer
'E'/'A'in loop bounds when teaching readability over raw ASCII - Compare with program 2 (each row starts at E and counts down along the row)
- Lowercase: use
base = 97andhigh = 97 + rows - 1 - Validate
cinand keeprowsin a safe range
Avoid
- Mixing this with program 6 (forward letters, fixed E on the right)
- Using
j++when you need reverse order along the row - Dropping below
65in the inner condition without intending non-letter output
Key Takeaways
Outer loop lowers the starting letter; inner loop prints down to a fixed 'A' (code 65).
Descending for loops match descending letters on the screen.
General form: high = 65 + rows - 1, i from high to 65, j from i to 65.
Still O(n²) characters for n rows.
❓ Frequently Asked Questions
i = 69, j runs 69, 68, …, 65 → EDCBA. When i = 68, j runs 68 down to 65 → DCBA, and so on.j >= 65, and the last iteration prints j == 65, which is 'A'.Explore More C++ Alphabet Patterns!
Program 6 grows toward E; program 7 shrinks toward A—same triangle sizes, different directions.
This pattern mirrors program 6 in the same way program 5 mirrors program 1: swap whether the outer loop widens or narrows the slice while keeping the other edge fixed at A or E.
12 people found this page helpful
