C++ Alphabet Triangle Pattern (Increasing Start)

Beginner
7 min read
Updated: Sep 2026
3 programs
Live preview

What Is This Pattern?

An increasing-start alphabet triangle keeps a fixed end letter on every row, but moves the start one letter later each line — so the left edge walks forward while the right edge stays put.

Remember
Rule: on row with start i, print i..end

ABCDE
BCDE
CDE
DE
E         ← 5 rows (end = 'E')

Compare with Program 5 (same widths, but every row restarts at A and shortens the end) and Program 3 (grows while starting earlier toward a fixed end).

How to Solve It

Two ways to emit the same shape — classic nested char loops, or spaced letters for readability.

MethodIdeaBest for
Nested char loopsOuter picks start i; inner prints i..endLearning, interviews, exams
Spaced lettersSame bounds; print j << " "Clearer console demos once loops click

Pseudocode

Pseudocode
endChar = 'A' + rows - 1
for i from 'A' to endChar:
    for j from i to endChar:
        print j (no newline)
    print newline

Cheat sheet

GoalPattern
End letterchar endChar = char('A' + rows - 1);
Advance startfor (char i = 'A'; i <= endChar; i++)
Print i..endfor (char j = i; j <= endChar; j++) cout << j;
End the rowcout << "\n";
vs Program 5Program 5: start fixed at A, end shrinks
Letter totaln + (n−1) + … + 1 = n(n+1)/2

Printing Letters vs Starting a New Line

APIEffectUse for
cout << jStays on the same lineEach letter
cout << "\n"Ends the current lineAfter the inner loop finishes a row

Print letters without a newline, then end the row once.

Live Preview

Change the row count and the triangle updates instantly — every row still ends on the same letter.

Whole numbers from 1 to 10. Tap a chip or type a value — the preview redraws as you go.

Live result 5 rows · end E · 15 letters
ABCDE
BCDE
CDE
DE
E

Worked Walkthrough — End = E (5 rows)

Trace each start letter i and the suffix that runs to the fixed end.

i (start)Inner rangePrinted rowLetters
AA..EABCDE5
BB..EBCDE4
CC..ECDE3
DD..EDE2
EE..EE1

Total letter prints: 5 + 4 + 3 + 2 + 1 = 15 = 5×6/2. The right edge is always E; that triangular sum is why time is O(n²).

C++ Programs

Three complete programs: fixed A–E, row-count input, and a spaced-letter variant. Use View Output to reveal sample results.

Example 1 — Fixed End E

Hard-coded height — outer loop advances the start; inner loop always stops at E.

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

int main()
{
    for (char i = 'A'; i <= 'E'; i++)
    {
        for (char j = i; j <= 'E'; j++)
            cout << j;
        cout << "\n";
    }

    return 0;
}

How It Works

1. Outer loop picks the start. i runs from 'A' to 'E' — each row begins one letter later.

2. Inner loop runs to a fixed end. For each i, j runs from i to 'E', so every row ends with E.

3. Break the line. cout << "\n" after the inner loop starts the next (shorter) row.

When i = 'C' you get CDE; when i = 'E' you get E.

Example 2 — Row Count Input

Read the number of rows and compute endChar = 'A' + rows - 1. Prefer validating cin in real apps.

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

int main()
{
    int rows;
    cout << "Enter the number of rows: ";
    cin >> rows;

    char endChar = char('A' + rows - 1);
    for (char i = 'A'; i <= endChar; i++)
    {
        for (char j = i; j <= endChar; j++)
            cout << j;
        cout << "\n";
    }

    return 0;
}

How It Works

1. Scale with rows. For 4 rows, endChar becomes 'D'. Cap rows at 26 so endChar stays within A–Z.

2. Same nested-loop core. Only the source of endChar changes — the print logic matches Example 1.

3. Safer input tip. Prefer:

Safer input
if (!(cin >> rows) || rows < 1 || rows > 26)
{
    cout << "Enter a whole number from 1 to 26.\n";
    return 1;
}

Example 3 — Spaced Letters

Same bounds — print a trailing space after each letter so columns are easier to scan.

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

int main()
{
    char endChar = 'E';

    for (char i = 'A'; i <= endChar; i++)
    {
        for (char j = i; j <= endChar; j++)
            cout << j << " ";
        cout << "\n";
    }

    return 0;
}

How It Works

1. Bounds unchanged. Outer still advances i; inner still walks i..endChar.

2. Only the printed unit changes. Each cell becomes j + " ". Trim trailing spaces later if you need a compact line.

Edge Cases & Pitfalls

Check these before calling the solution done.

j from A

Wrong cousin pattern

If the inner loop starts at 'A' instead of i, you get Program 1 / Program 5 style prefixes. Start at i for this suffix triangle.

\n early

Column of letters

If cout << "\n" is inside the inner loop, each letter lands on its own line. Print letters without a newline; end the row only after the inner loop.

end shrinks

Confused with Program 5

Program 5 keeps start at A and shrinks the end. This pattern keeps the end fixed and advances the start.

rows = 1

Single A

Output is just A on one line — a good sanity check.

rows > 26

Beyond Z

Cap or reject — endChar leaves the alphabet. Keep rows in 1…26 for A–Z demos.

Bad cin

Validate rows

Check cin >> rows, require a positive whole number, and clamp to 26 before building endChar.

Time and Space Complexity

ProgramTimeExtra space
Nested loops (Examples 1–2)O(n²)O(1)
Spaced letters (Example 3)O(n²)O(1)

Total letters printed = n + (n−1) + … + 1 = n(n+1)/2, which is still quadratic in n.

Key Takeaways

  • Rule: start advances each row; end letter stays fixed.
  • Two loops: outer picks start i; inner prints i..end.
  • Break the row: cout << "\n" only after the inner loop.
  • Complexity: O(n²) time; O(1) extra space.

One line: for each start i from A to end, print i..end, then a newline.

Frequently Asked Questions

The outer loop picks the starting letter (A, then B, then C…). The inner loop prints from that start up to the fixed end letter (E in the 5-row example). Each row drops the leftmost character and becomes shorter.
Program 5 restarts each row at A and shortens the end letter (ABCDE, ABCD, …). Program 6 shifts the start letter forward each row while keeping the same end letter (ABCDE, BCDE, …).
Program 3 grows while starting earlier (E, DE, CDE). This pattern shrinks while starting later (ABCDE, BCDE, CDE). Both keep a fixed right edge at the top letter.
Because the inner loop always stops at the same end letter ('E'), so the last printed character is fixed.
O(n²) for n rows, because total printed characters are n+(n−1)+…+1 = n(n+1)/2.
Yes. Read rows from cin, set endChar = char('A' + rows - 1), then loop i from 'A' to endChar and print j from i up to endChar.
After cin >> rows, check failure, require n ≥ 1, and cap at 26 so the end letter stays within A–Z.
Yes. Use 'a' as the base: endChar = char('a' + rows - 1), then loop the same way with j from i up to endChar.

Did you know?

Each row starts one letter later (A, B, C, …), but always prints up to the same end letter. For 5 rows, the output is ABCDE, BCDE, CDE, DE, E.

Next: Reverse Decreasing Triangle

Same shrinking widths, opposite letter direction — EDCBA, DCBA, CBA…

Program 7 tutorial →

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