Reverse Right-Angled Triangle Alphabet Pattern in C++

What You’ll Learn
How to print a reverse alphabet right-angled triangle in C++: each row has one more character than the last, and letters run from 'E' downward along the row (for five rows), using nested for loops with descending loop variables and cout << (char) j.
The result is E, ED, EDC, EDCB, EDCBA—same geometry as program 1, but descending in the alphabet on each row.
⭐ Pattern Output
For 5 rows:
E
ED
EDC
EDCB
EDCBAComplete C++ Program
Fixed five rows: i steps down from 69 ('E') to 65 ('A'); j prints from the top letter down to i.
#include <iostream>
using namespace std;
int main() {
int i, j;
for (i = 69; i >= 65; i--) {
for (j = 69; j >= i; j--)
cout << (char) j;
cout << "\n";
}
return 0;
}🧠 How It Works
Headers and namespace
#include <iostream> and using namespace std; let you use cout for output.
Outer loop (rows)
for (i = 69; i >= 65; i--) runs five times. Smaller i means the inner loop runs longer, so each row adds one more letter.
Inner loop (descending letters)
for (j = 69; j >= i; j--) prints from 'E' down to the current i. (char) j turns the ASCII code into a letter for cout.
New line
cout << "\n"; ends the row before the outer loop decreases i again.
Reverse letter triangle
Total characters: 1+2+…+n = n(n+1)/2, so time complexity is O(n²) for n rows.
Variation — User Input Version
For rows rows, the highest letter is 'A' + rows - 1. Store that as top and use it instead of 69:
#include <iostream>
using namespace std;
int main() {
int rows;
int i, j;
cout << "Enter the number of rows: ";
cin >> rows;
int top = 65 + rows - 1;
for (i = top; i >= 65; i--) {
for (j = top; j >= i; j--)
cout << (char) j;
cout << "\n";
}
return 0;
}💡 Tips for Enhancement
Try These
- Replace
65and69with'A'and'E'in the fixed version for readability - Use
static_cast<char>(j)instead of(char) j - Compare with program 1 for the forward A–B–C triangle
- Try lowercase by using
'a'as the base instead of65
Avoid
- Swapping the inner bounds so
jruns upward—you needj >= iwithj--for this shape - Printing
jwithout a cast (you would see integers, not letters) - Forgetting that
topmust be65 + rows - 1when generalizing row count
Key Takeaways
Row k prints k letters from the top character down: the inner loop always starts at top (e.g. 'E' when rows == 5) and ends at i.
Descending j with cout << (char) j walks the alphabet backward on each row.
For variable rows, set top = 65 + rows - 1 so the triangle height matches the letter range.
Complexity stays O(n²) for n rows, same as program 1 or star triangles.
❓ Frequently Asked Questions
j from 69 down to i. Each value is printed as a character, so you see E, then ED, then EDC, and so on.i is the smallest letter code on each row. It moves from E toward A so each row extends one step further left in the alphabet while still starting from E on the right.Explore More C++ Alphabet Patterns!
Combine forward, reverse, and mixed letter patterns to master character arithmetic in C++.
This program is the mirror of program 1 in terms of shape: both print 1+2+…+n letters. Program 1 grows j upward from 'A'; here j steps down from 'E' (for five rows) toward i.
12 people found this page helpful
