Increasing Start Letter Alphabet Triangle in C

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

What You’ll Learn

Each row starts one letter later (A, B, C, …) but always runs through to 'E' on the first line’s alphabet range, so widths go 5, 4, 3, 2, 1.

Contrast program 5 (same widths, but every row restarts at A) and program 3 (different left/right edge rule).

⭐ Pattern Output

For five rows ending at 'E':

Output
ABCDE
BCDE
CDE
DE
E
1

Complete C Program (ASCII Values)

65 is 'A' and 69 is 'E' in ASCII. printf("%c", j) prints the character for code j.

c
#include <stdio.h>

int main() {
    int i, j;

    for (i = 65; i <= 69; ++i) {
        for (j = i; j <= 69; ++j) {
            printf("%c", j);
        }
        printf("\n");
    }

    return 0;
}

Same logic with character literals (often clearer): for (i = 'A'; i <= 'E'; ++i) and for (j = i; j <= 'E'; ++j).

🧠 How It Works

1

Outer loop: start code

i takes values 6569 (A–E). That is the first letter printed on each row.

Start moves right
2

Inner loop: run to E

j runs from i up to 69, so every row ends at the same letter E.

Fixed end
3

Print as characters

printf("%c", j) outputs the letter for integer code j.

%c
4

Line length

Row starting at code i prints 69 - i + 1 letters: five when i == 65, down to one when i == 69.

Shrinking width
=

Five rows, fifteen letters

Total prints = 5+4+3+2+1 = 15 = n(n+1)/2 for n = 5 — O(n²) in general.

2

Variation — User Input Version

Set endChar = 'A' + rows - 1 so the last row is a single letter and the first row spells A through that letter.

c
#include <stdio.h>

int main() {
    int rows, i, j;
    int endChar;

    printf("Enter the number of rows: ");
    scanf("%d", &rows);

    endChar = 'A' + rows - 1;

    for (i = 'A'; i <= endChar; ++i) {
        for (j = i; j <= endChar; ++j) {
            printf("%c", j);
        }
        printf("\n");
    }

    return 0;
}

💡 Tips for Enhancement

Try These

  • Prefer 'A''E' in loops instead of 65–69 unless you are demonstrating ASCII
  • Try lowercase: endChar = 'a' + rows - 1
  • For A, AB, ABC, … see program 1
  • Check scanf return value and sensible bounds on rows

Avoid

  • Hard-coding 69 when you already have a variable endChar
  • Assuming ASCII without noting your platform (fine for typical interview C)
  • Using %d if you want letters—use %c

Key Takeaways

1

Outer loop = starting letter; inner loop = sweep to a fixed last letter.

2

Integer codes and character literals are interchangeable in these loops.

3

Row count n still implies O(n²) total characters.

4

Pairs naturally with program 5 (same geometry, different restart rule).

❓ Frequently Asked Questions

The outer variable i is the first code printed on the line. The inner j runs from i through 69 ('E'), so the first line is full A–E and each next line drops the leftmost letter.
Yes. Use 'A' and 'E' (or an endChar variable) in the loop bounds; the compiled code is the same idea.
Program 5 resets to A every row, so lines are ABCDE, ABCD, … Here the start letter moves B, C, D, … while the end stays E.
O(n²) for n rows: n(n+1)/2 printed characters.

Explore More C Alphabet Patterns!

Switching between ASCII codes and character literals is a core C skill.

All Alphabet Patterns →
Did you know?

The rightmost column is always 'E' (or your endChar) because the inner loop always stops there—only the left bound moves.

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