Inverted Right-Angled Alphabet Triangle in C++

What You’ll Learn
Print an inverted letter triangle: the first row is the longest (ABCDE for five rows), then each row drops one letter while still starting from 'A' and counting up to the current upper bound.
This pairs with program 1 (growing rows). Here the outer loop runs the high letter from E down to A instead of growing the row width from A upward.
⭐ Pattern Output
For 5 rows:
ABCDE
ABCD
ABC
AB
AComplete C++ Program
Outer i from 69 down to 65; inner j from 65 to i, printing (char) j.
#include <iostream>
using namespace std;
int main() {
int i, j;
for (i = 69; i >= 65; i--) {
for (j = 65; j <= i; j++)
cout << (char) j;
cout << "\n";
}
return 0;
}🧠 How It Works
Headers and namespace
#include <iostream> and using namespace std; enable cout.
Outer loop shrinks the row
for (i = 69; i >= 65; i--) sets the last letter on the row: E, then D, then C, … Smaller i means a shorter inner loop.
Inner loop always starts at A
for (j = 65; j <= i; j++) prints A through the letter with code i. Each new row resets implicitly because j starts at 65 again.
New line
cout << "\n" after the inner loop ends the row before i decreases.
Inverted triangle
Total characters: n(n+1)/2 for n rows — O(n²).
Variation — User Input Version
Let base = 65 ('A') and top = base + rows - 1. Run i from top down to base:
#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 top = base + rows - 1;
for (i = top; i >= base; i--) {
for (j = base; j <= i; j++)
cout << (char) j;
cout << "\n";
}
return 0;
}💡 Tips for Enhancement
Try These
- Write
'A'and'E'instead of65and69in the fixed five-row version - For the growing triangle, use program 1
- Use
base = 97for a lowercase inverted triangle - Compare with inverted stars in C++ star pattern 2
Avoid
- Incrementing
ion the outer loop when you need the row width to shrink - Starting
jatihere—that would change the pattern (see programs 3 and 4) - Printing
jwithout casting tochar
Key Takeaways
Counting i down from the top letter code shortens each row while the inner loop always begins at 'A'.
j from 65 to i prints a contiguous forward slice of the alphabet on each line.
For variable rows, set top = 65 + rows - 1 and loop i from top down to 65.
Same total work as program 1: O(n²) characters for n rows.
❓ Frequently Asked Questions
i is 69, the inner loop prints five letters. Each time i drops by one, the inner loop runs one fewer iteration, so the rows get shorter.65 is 'A'. Resetting the inner loop to A each outer iteration gives ABCDE, then ABCD, then ABC, and so on—not one long alphabet across lines.i decreases, so lines shrink. The inner “A through bound” idea is the same.Explore More C++ Alphabet Patterns!
Inverted shapes are the same loop tricks as growing triangles—only the outer bound changes direction.
If you swap the outer loop to count up from 65 to 69 with the same inner j loop, you get program 1’s output (A, AB, ABC, …) instead of an inverted triangle.
12 people found this page helpful
