Reverse Repeating-Letter Triangle in C++

Beginner
⏱️ 5 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Nested Loops

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:

Output
E
DD
CCC
BBBB
AAAAA
1

Complete C++ Program

Outer i from 69 to 65. Inner j from 69 down to i; each iteration prints (char) i.

C++
#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

1

Headers and namespace

#include <iostream> and using namespace std; enable cout.

Setup
2

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.

Descending letter
3

Inner loop: repeat count

for (j = 69; j >= i; j--) runs 69 - i + 1 times. Each time, cout << (char) i prints the same letter.

Repeat
4

New line

cout << "\n" ends the row; i-- moves to the next letter.

Next row
=

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+…+nO(n²).

2

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:

C++
#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 index k from 1 to n, ch = (char)(top - k + 1), inner loop k times
  • Lowercase: use base = 97 and top = 97 + rows - 1
  • Cap rows so letters stay in the range you want

Avoid

  • cout << (char) j unless you want descending letters along the row
  • Incrementing i on the outer loop when you need E → A row order
  • Rows so large that i drops below your intended alphabet floor

Key Takeaways

1

Outer i is both the row’s letter and the lower bound for j.

2

Inner loop iterations = top - i + 1 with fixed top = 69 in the five-row demo.

3

O(n²) characters for n rows.

4

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.
In the fixed version, 69 is 'E' and acts as top. For variable rows, use top = 65 + rows - 1 and start j at top each time.
Program 9 walks i upward from A; program 10 walks i downward from E. The inner bounds are built the same way relative to top and i.
O(n²) for n rows: n(n+1)/2 characters.

Explore More C++ Alphabet Patterns!

Program 9 and 10 share the same nested-loop skeleton—only the outer i direction changes.

All Alphabet Patterns →
Did you know?

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.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful