Reverse Repeating-Letter Triangle in C++

What You’ll Learn
Same repeating idea as program 9, but letters run E → D → C → B → A while row widths still grow 1, 2, 3, 4, 5.
The reference uses outer i from 69 down to 65 and always prints (char) i; the inner loop only decides how many copies.
⭐ Pattern Output
For 5 rows:
E
DD
CCC
BBBB
AAAAAComplete C++ Program
Outer i from 69 to 65. Inner j from 69 down to i; each iteration prints (char) 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) i;
cout << "\n";
}
return 0;
}🧠 How It Works
Headers and namespace
#include <iostream> and using namespace std; enable cout.
Outer loop: row letter
for (i = 69; i >= 65; i--) picks E, then D, then C, B, A. That value is what you print on the row.
Inner loop: repeat count
for (j = 69; j >= i; j--) runs 69 - i + 1 times. Each time, cout << (char) i prints the same letter.
New line
cout << "\n" ends the row; i-- moves to the next letter.
E-first, same widths
The outer loop still produces row widths 1, 2, …, n; only the printed letter runs E→A. Total characters 1+2+…+n — O(n²).
Variation — User Input Version
Let top = 65 + rows - 1 and base = 65. Outer i from top down to base; inner j from top down to i:
#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 = top; j >= i; j--)
cout << (char) i;
cout << "\n";
}
return 0;
}💡 Tips for Enhancement
Try These
- Forward repeat triangle: program 9
- Same shape with
char ch: row indexkfrom 1 to n,ch = (char)(top - k + 1), inner loopktimes - Lowercase: use
base = 97andtop = 97 + rows - 1 - Cap
rowsso letters stay in the range you want
Avoid
cout << (char) junless you want descending letters along the row- Incrementing
ion the outer loop when you need E → A row order - Rows so large that
idrops below your intended alphabet floor
Key Takeaways
Outer i is both the row’s letter and the lower bound for j.
Inner loop iterations = top - i + 1 with fixed top = 69 in the five-row demo.
O(n²) characters for n rows.
Mirrors program 9: ascending vs descending outer letter with the same triangle widths.
❓ Frequently Asked Questions
j is only a counter. The repeated symbol on the row is i.69 is 'E' and acts as top. For variable rows, use top = 65 + rows - 1 and start j at top each time.i upward from A; program 10 walks i downward from E. The inner bounds are built the same way relative to top and i.Explore More C++ Alphabet Patterns!
Program 9 and 10 share the same nested-loop skeleton—only the outer i direction changes.
An equivalent char version: for row k from 1 to n, set ch = (char)('A' + n - k) and print ch exactly k times—no inner index j tied to ASCII.
12 people found this page helpful
