Sequential Decreasing Alphabet Triangle in C

Beginner
⏱️ 8 min read
📚 Updated: Aug 2026
🎯 3 Code Examples
🚀 Live Preview
Nested Loops

What You’ll Learn

Print a continuous alphabet sequence across rows, while each next row prints one fewer letter than the previous. Keep a running counter (k++) so the sequence goes A through O for five rows. Compare Program 22 (right-aligned growing sequential pyramid) and Program 13 (left-aligned growing sequential). Includes a live preview, worked C examples, edge cases, and complexity.

Shape Rule

Shrinking rows

Lengths 5, 4, 3, 2, 1 with continuous letters.

Running k

Never reset

k++ streams A…O across all rows.

Inner Shrink

n..i

Loop j from n down to i for row length.

Spacing

%c

Letter plus trailing space for readable columns.

Live Preview

1–6 rows

Pick a height (max 6 keeps letters within A–U).

O(n²)

Complexity

Total letters = n(n+1)/2.

Introduction

A sequential decreasing alphabet triangle fills shrinking rows from a single continuous letter stream, so the alphabet never restarts at the start of a new line.

In C you solve it with nested loops, a running char counter, and optional width formatting for readable spacing.

Why it matters?

It combines continuous counters with shrinking loop bounds — the mirror image of growing sequential triangles.

Key Highlights

Stream

k never resets between rows.

Shrink

Each row prints one fewer letter.

Format

%2c plus a trailing space.

vs Grow

Opposite of Program 13 / 22 growth.

In short: for each row i, print n - i + 1 letters from the shared k++ stream, then call printf("\n").

📝 Problem & Approach

Given a row count n (or fixed 5), print a left-aligned triangle of continuous alphabet letters with shrinking row lengths.

c
// Five rows (continuous stream; lengths 5..1)
// A B C D E
// F G H I
// J K L
// M N
// O

Inputs & Outputs

ItemTypeDescription
nintNumber of rows. Letter count = n(n+1)/2 (15 for n=5).
Printed outputtextContinuous letters in shrinking left-aligned rows.

Minimal workflow

Pseudocode
k = 'A'
for i in 1..n:
    for j from n down to i:
        print k with spacing; k++
    print newline

Approach comparison

ApproachIdeaBest for
j from n down to iClassic shrinking boundMatching this sample
Print (n-i+1) timesExplicit count per rowClearer reading / teaching rewrite

⚡ Quick Reference

GoalPattern
Counterchar k = 'A'; (outside outer loop)
Rowsfor (int i = 1; i <= n; i++)
Shrink lettersfor (int j = n; j >= i; j--)
Print letterprintf("%c ", k++);
Growing sequentialSee Program 13 / Program 22

📋 Stream vs Shrink vs Newline

Same triangle — three roles that build the decreasing pattern.

k outside
stream

Continues A, B, C… across every row

j = n..i
shrink

Row length falls by one each time

printf("%c ", k++)
space

Letter plus separator space

printf("\n")
break

Ends the row; k keeps its value

Context

When This Pattern Shows Up

Reach for this when teaching continuous counters with shrinking loop bounds.

  1. After growing sequential

    Keep the running counter; flip the row lengths to shrink.

  2. Compare with Program 22

    Same stream idea; growing + right-align vs shrinking + left-align.

  3. Format-width drills

    Practice %2c spacing in monospace output.

  4. Triangular counts

    Show why total letters equal n(n+1)/2.

  5. Not a UI layout tool

    This is a console teaching pattern — not how you build modern app screens.

Key benefit: keeping k outside while shrinking the inner bound is the cleanest way to teach continuous fill into a decreasing triangle.

🔮 Live Preview

Choose between 1 and 6 rows and draw the sequential decreasing triangle in the browser.

Try 5 (through O) or 3 (through F). Max 6 keeps letter count within A–U.

Live result
Press "Draw pattern".

Examples Gallery

Three complete C programs — fixed 5 rows, scanf row count, and explicit letters-per-row count. Click View Output to reveal sample console results.

📚 Getting Started

Print five shrinking rows with a continuous letter stream.

Example 1 — Fixed 5 Rows

One counter k supplies letters; the inner loop decides how many times to print it in each row.

c
#include <stdio.h>

int main() {
    int i, j;
    char k = 'A';

    for (i = 1; i <= 5; ++i) {
        for (j = 5; j >= i; --j) {
            printf("%c ", k++);
        }
        printf("\n");
    }

    return 0;
}

How It Works

When i = 3, the inner loop runs three times and prints the next three letters from k (J K L). Because k is outside the outer loop, the next row continues at M.

📈 Practical Variant

Let the user choose how many rows to print.

Example 2 — Row Count Input

If rows are large, letters will go beyond Z unless you add wrapping. Check scanf and a letter-budget cap in real apps.

c
#include <stdio.h>

int main() {
    int n, i, j;
    char k = 'A';

    printf("Enter number of rows (like 5): ");
    scanf("%d", &n);
    if (n < 1) return 0;

    for (i = 1; i <= n; ++i) {
        for (j = n; j >= i; --j) {
            printf("%c ", k++);
        }
        printf("\n");
    }

    return 0;
}

How It Works

Same stream and shrink rules; only the shared width follows n. Letter count is n(n+1)/2 — cap so it stays ≤ 26 for A–Z only.

⚡ Explicit Style

Same shape with an explicit letters-per-row count.

Example 3 — Explicit Count Per Row

Often clearer to read: print n - i + 1 letters from the shared stream.

c
#include <stdio.h>

int main() {
    int n = 5;
    char k = 'A';
    int i, t, count;

    for (i = 1; i <= n; ++i) {
        count = n - i + 1;
        for (t = 0; t < count; ++t) {
            printf("%c ", k++);
        }
        printf("\n");
    }

    return 0;
}

How It Works

Row 1 prints 5 letters; row 5 prints 1. Same continuous k++; only the loop bound style changes.

🧠 How the Algorithm Prints Rows

1

k is a running alphabet counter

We start at 'A' and increment only when printing a letter.

Stream
2

Inner loop length decreases

The inner loop runs 5, then 4, then 3, etc. as i increases.

Shrink
3

Formatting keeps spacing readable

%2c prints each letter in a 2-column field. A trailing space separates letters.

Align
4

New line

printf("\n") ends the row so the next shorter row continues the same k.

Break
=

One continuous sequence

Total letters printed over n rows is n(n+1)/2, so work grows as O(n²).

🔎 Worked Walkthrough — 5 rows

Trace each row’s length and the letters taken from the running counter.

iLettersCountPrinted row
1A..E5A B C D E
2F..I4F G H I
3J..L3J K L
4M..N2M N
5O1O

Total letters: 5+4+3+2+1 = 15 (A through O).

Use Cases

Where this sequential decreasing triangle shows up beyond the homework prompt.

1. Continuous Fill Labs

Clearest demo of a counter that never resets across shrinking rows.

Example: reset k once and see every row start at A.

2. Pair with Program 22

Same stream — growing right-aligned vs shrinking left-aligned.

Example: print both for n = 5 side by side.

3. Bound Flip Drill

Change j = 1..i to grow instead of shrink.

Example: rebuild Program 13 from this page.

4. Explicit Count Rewrite

Teach count = n - i + 1 (Example 3).

Example: compare classic j-bound vs count loops.

5. Complexity Intuition

Triangular letter counts make O(n²) easy to see.

Example: 5 rows print 15 letters.

6. Bridge to Program 26

Next pattern rotates fixed-length alphabet rows.

Example: continue to Program 26.

Pro Tip: say “keep counting letters, print one fewer each row” before coding — that story prevents resetting k or growing the rows by mistake.

Advantages

Why this pattern earns a spot after growing sequential triangles.

  1. 1. Instant Visual Feedback

    A reset counter or growing bounds shows up immediately.

  2. 2. Two Clear Rewrites

    j-bound or explicit count teach the same shape.

  3. 3. Mirror of Growing Triangles

    A natural pair with Programs 13 and 22.

  4. 4. O(1) Extra Memory

    Streaming output needs no storage beyond loop variables.

Pro Tip: learn the classic j = n..i version first; treat the explicit count rewrite as a clarity upgrade afterward.

Usage Tips

Small habits that keep sequential decreasing triangles clean.

  1. 1. Keep k Outside

    Do not reset the counter each row if you want continuous letters.

  2. 2. Shrink, Don’t Grow

    Inner length should be n - i + 1, not i.

  3. 3. Check scanf

    Avoid crashes when the user types letters instead of a number.

  4. 4. Cap the Letter Budget

    Keep n(n+1)/2 ≤ 26 for A–Z-only output.

  5. 5. Use a Monospace Font

    Proportional fonts make %2c spacing look uneven.

Pro Tip: if every row starts with A, you almost certainly reset k inside the outer loop.

Common Pitfalls

Mistakes that commonly break sequential decreasing triangles.

  1. 1. Resetting the Counter

    Each row starts at A again — that is a different pattern.

    → Keep k outside the outer loop.

  2. 2. Growing Instead of Shrinking

    Using j = 1..i builds an inverted (growing) triangle.

    → Use j = n..i or count = n - i + 1.

  3. 3. Proportional Font Preview

    Columns look uneven even when the code is correct.

    → View output in a monospace terminal/font.

  4. 4. Unchecked scanf

    Letters or empty input leave n uninitialized.

    → Check scanf and re-prompt on failure.

  5. 5. Walking Past Z

    Large n needs more than 26 letters.

    → Cap n so n(n+1)/2 ≤ 26, or define wrap/stop policy.

Edge Cases

Check these inputs before calling the solution done.

n = 1

Single letter

Output is just A.

n = 5

Classic sample

15 letters through O.

n = 3

Smaller triangle

Through F (Example 2).

n = 7

Past Z

Needs 28 letters — decide wrap/stop policy.

Bad input

Non-numeric scanf

scanf fails silently — check the return value.

Case

Lowercase

Same loops with k = 'a'.

🎯 Practice Problems

Try these variations to lock in the pattern.

1. Flip to growing

  • Print sequential letters with lengths 1..n
  • Compare with Program 13

2. Right-align the stream

3. Explicit count version

  • Use count = n - i + 1 (Example 3)
  • Confirm output matches the classic loop

4. Continue to Program 26

  • Rotating alphabet rows of fixed length
  • See Program 26

Notes

  • Continuous k. Increment only when printing a letter; never reset between rows for this pattern.
  • Row lengths shrink: n, n-1, …, 1 (not grow).
  • Letter count for n rows is the triangular number n(n+1)/2.
  • Unlike Program 22, this sample is left-aligned and shrinks rather than pads to the right.

Quick Takeaway: keep counting letters across rows, print one fewer letter each time, then break the line.

⏱️ Time and Space Complexity

ProgramTimeExtra space
Classic / input (Examples 1–2)O(n²)O(1)
Explicit count (Example 3)O(n²)O(1)

Total printed letters are n+(n-1)+…+1 = n(n+1)/2, so time is O(n²).

Wrap Up

🎉 Conclusion

The sequential decreasing alphabet triangle is a small nested-loop exercise with lasting payoff: a continuous letter counter paired with shrinking row lengths. Master the classic A…O sample, then try user input and the explicit count rewrite.

Practice the three examples above, then continue to Program 26’s rotating alphabet pattern.

Keep k outside, shrink the inner bound each row, print the next letters, then break the line.

💡 Best Practices

✅ Do

  • Keep the letter counter outside the outer loop
  • Shrink row length with j = n..i (or an explicit count)
  • View %2c output in a monospace font
  • Check scanf and cap the letter budget
  • State O(n²) / n(n+1)/2 when asked about complexity

❌ Don’t

  • Reset k each row for this pattern
  • Grow rows with j = 1..i by accident
  • Assume proportional fonts will align columns
  • Ignore overflow past Z on large n
  • Call printf("\n") inside the letter loop

Key Takeaways

Knowledge Unlocked

Five things to remember about this alphabet pattern

Print the sequential decreasing alphabet triangle the beginner-friendly way.

5
Core concepts
k 02

Counter

Never reset

Code
03

Length

n..1 each row

Code
04

New line

Ends each row

I/O
O 05

Complexity

O(n²) time

Analysis

❓ Frequently Asked Questions

Because the pattern is one continuous alphabet stream A through O. Resetting k would restart each row from A.
So the sequence continues across rows (A, B, C, ...). If you reset k each row, every row would start at A again.
For the fixed 5-row example, the row lengths are 5, 4, 3, 2, 1. Each new row prints one fewer letter.
A trailing space (or width-2 formatting) separates letters so columns stay readable in a monospace terminal.
Build a row and trim it, or print a space only between letters (not after the last letter in the row).
Both use a continuous k++ stream. Program 22 grows rows and right-aligns with pad cells; this pattern shrinks row length each time and stays left-aligned.
O(n²) for n rows because total prints are 1+2+...+n = n(n+1)/2.
Check scanf("%d", &n) == 1, require n ≥ 1, and cap so n(n+1)/2 ≤ 26 if you want only A–Z letters.

Did you Know? 🔊

One counter k starts at A and never resets. The outer loop controls row count; the inner loop length decreases each row (5, 4, 3, 2, 1). Using printf("%c ", k++) (or %2c) keeps a clean spaced layout in monospace output.

Continue to Alphabet Pattern 26

Next up: rotating alphabet patterns with nested loops.

Program 26 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