Reverse Right-Angled Triangle Alphabet Pattern in C++

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

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:

Output
E
ED
EDC
EDCB
EDCBA
1

Complete C++ Program

Fixed five rows: i steps down from 69 ('E') to 65 ('A'); j prints from the top letter down to 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) j;
        cout << "\n";
    }
    return 0;
}

🧠 How It Works

1

Headers and namespace

#include <iostream> and using namespace std; let you use cout for output.

Setup
2

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.

Row control
3

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.

Print
4

New line

cout << "\n"; ends the row before the outer loop decreases i again.

Line break
=

Reverse letter triangle

Total characters: 1+2+…+n = n(n+1)/2, so time complexity is O(n²) for n rows.

2

Variation — User Input Version

For rows rows, the highest letter is 'A' + rows - 1. Store that as top and use it instead of 69:

C++
#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 65 and 69 with '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 of 65

Avoid

  • Swapping the inner bounds so j runs upward—you need j >= i with j-- for this shape
  • Printing j without a cast (you would see integers, not letters)
  • Forgetting that top must be 65 + rows - 1 when generalizing row count

Key Takeaways

1

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.

2

Descending j with cout << (char) j walks the alphabet backward on each row.

3

For variable rows, set top = 65 + rows - 1 so the triangle height matches the letter range.

4

Complexity stays O(n²) for n rows, same as program 1 or star triangles.

❓ Frequently Asked Questions

The inner loop runs 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.
Use alphabet pattern program 1: outer i from 65 upward and inner j from 65 to i.
O(n²) for n rows: 1+2+…+n = n(n+1)/2 characters.

Explore More C++ Alphabet Patterns!

Combine forward, reverse, and mixed letter patterns to master character arithmetic in C++.

All Alphabet Patterns →
Did you know?

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.

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