Reverse Alphabet Decreasing Triangle in C++

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

What You’ll Learn

Print a triangle whose first row is the full reverse run from E to A, then each row drops the leftmost letter: EDCBA, DCBA, CBA, BA, A.

Pair this with program 6 (ABCDE, BCDE, … ending at E). Here both the outer start letter and the inner print direction move toward A.

⭐ Pattern Output

For five rows from 'E' down to 'A':

Output
EDCBA
DCBA
CBA
BA
A
1

Complete C++ Program

Outer i from 69 ('E') down to 65 ('A'); inner j from i down to 65, printing (char) j.

C++
#include <iostream>
using namespace std;

int main() {
    int i, j;
    for (i = 69; i >= 65; i--) {
        for (j = i; j >= 65; j--)
            cout << (char) j;
        cout << "\n";
    }
    return 0;
}

🧠 How It Works

1

Headers and namespace

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

Setup
2

Outer loop: high letter

for (i = 69; i >= 65; i--) sets the first character on each row: E, D, C, B, A.

Start moves left
3

Inner loop: down to A

for (j = i; j >= 65; j--) prints from the row start down to 'A' with cout << (char) j.

Fixed low end
4

Row length

Row starting at code i prints i - 65 + 1 characters: 5, 4, 3, 2, 1.

Shrinking
=

Fifteen letters total

For n = 5 rows: 5+4+3+2+1 = 15 — O(n²) in general.

2

Variation — User Input Version

high = 65 + rows - 1 is the first row’s leftmost letter (e.g. 68 = D for four rows). Loop i from high down to 65:

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 high = base + rows - 1;
    for (i = high; i >= base; i--) {
        for (j = i; j >= base; j--)
            cout << (char) j;
        cout << "\n";
    }

    return 0;
}

💡 Tips for Enhancement

Try These

  • Prefer 'E' / 'A' in loop bounds when teaching readability over raw ASCII
  • Compare with program 2 (each row starts at E and counts down along the row)
  • Lowercase: use base = 97 and high = 97 + rows - 1
  • Validate cin and keep rows in a safe range

Avoid

  • Mixing this with program 6 (forward letters, fixed E on the right)
  • Using j++ when you need reverse order along the row
  • Dropping below 65 in the inner condition without intending non-letter output

Key Takeaways

1

Outer loop lowers the starting letter; inner loop prints down to a fixed 'A' (code 65).

2

Descending for loops match descending letters on the screen.

3

General form: high = 65 + rows - 1, i from high to 65, j from i to 65.

4

Still O(n²) characters for n rows.

❓ Frequently Asked Questions

When i = 69, j runs 69, 68, …, 65 → EDCBA. When i = 68, j runs 68 down to 65 → DCBA, and so on.
The inner loop condition is j >= 65, and the last iteration prints j == 65, which is 'A'.
Program 6 walks forward along each row up to E. Program 7 walks backward along each row down to A and shifts the start left each time.
O(n²) for n rows: n(n+1)/2 characters.

Explore More C++ Alphabet Patterns!

Program 6 grows toward E; program 7 shrinks toward A—same triangle sizes, different directions.

All Alphabet Patterns →
Did you know?

This pattern mirrors program 6 in the same way program 5 mirrors program 1: swap whether the outer loop widens or narrows the slice while keeping the other edge fixed at A or E.

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