New: 213 pattern programs with tested code in C, C++, Java and Python Explore patterns

Descending Alphabet Triangle (A, B A, C B A)

The descending alphabet triangle starts each row at its own letter and counts back to A: A, then B A, then C B A. The first column spells A to E and the last column is all A.

Quick answer: Row i prints i letters, and the letter at position j is 'A' + i − j. On row 3 that gives C, B, A. Every row ends at A and starts one letter later than the row above.

This program is part of the String Patterns collection.

Table of contents8 sections
  1. Descending Alphabet Triangle output
  2. How the descending alphabet triangle works
  3. Descending Alphabet Triangle in C
  4. Descending Alphabet Triangle in C++
  5. Descending Alphabet Triangle in Java
  6. Descending Alphabet Triangle in Python
  7. Time and space complexity
  8. Frequently asked questions

Descending Alphabet Triangle output

Output (n = 5):

A
B A
C B A
D C B A
E D C B A
Descending Alphabet Triangle layout diagram, row by row (n = 5)
How each row of the descending alphabet triangle is built (n = 5). Blue cells are printed characters; grey dots are spaces.

Same shape, other characters: the 0-1 (Binary) Triangle, Alphabet Triangle, Hash (#) Right Triangle, Incremental Alphabet Triangle and Reverse Alphabet Triangle programs draw this same outline with different characters. Putting them side by side shows which part of the loop decides the shape and which part decides what is printed.

How the descending alphabet triangle works

Here both loop counters matter. i sets the first letter of the row and j walks back from it. The expression i − j is 0 at the end of every row, which is why each row lands on A. It is the letter version of the descending number triangle (1, 21, 321).

  1. Run the outer loop for i from 1 to n, one row per pass.
  2. Print i letters (letter number i − j + 1).
  3. Move to the next line.

Key takeaways

  • Each row starts at its own letter and counts back to A.
  • 'A' + i − j is the row letter minus the steps taken.
  • The first column is A, B, C, D, E; the last column is all A.
  • It is the mirror image, letter by letter, of the alphabet triangle.

Descending Alphabet Triangle in C

#include <stdio.h>

int main(void) {
    int n = 5;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++)
            printf("%c ", 'A' + i - j + 1 - 1);
        printf("\n");
    }
    return 0;
}

Descending Alphabet Triangle in C++

#include <iostream>
using namespace std;

int main() {
    int n = 5;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++)
            cout << char('A' + i - j + 1 - 1) << " ";
        cout << endl;
    }
    return 0;
}

Descending Alphabet Triangle in Java

public class DescendingAlphabetTriangle {
    public static void main(String[] args) {
        int n = 5;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++)
                System.out.print((char) ('A' + i - j + 1 - 1) + " ");
            System.out.println();
        }
    }
}

Descending Alphabet Triangle in Python

n = 5

for i in range(1, n + 1):
    for j in range(1, i + 1):
        print(chr(ord('A') + i - j + 1 - 1), end=" ")
    print()

Time and space complexity

The program prints one character for each position in the pattern, so for n rows it runs in O(n²) time. It only needs a few loop variables, so the extra memory is O(1).

Frequently asked questions

How is it different from E, E D, E D C?

The reverse alphabet triangle always starts at E. This one starts at the row’s own letter, so row 2 is B A here but E D there.

Why does every row end with A?

At the last position of row i, j equals i, so the letter is 'A' + 0, which is A.

How do I print it without spaces?

Drop the space after each letter: the rows become A, BA, CBA, DCBA, EDCBA.

Can I right-align it?

Yes. Print n − i double spaces before each row, because each letter takes two characters with its space.

This tutorial was drafted with AI assistance. Spotted a mistake? Tell us and we fix it. Read our editorial policy.

Quick check: can you predict the output?

Answer from the code, then check. Every answer comes from the real output above.

Pattern 9 of 22 in String Patterns

 

Still stuck? Ask AI to explain this code

Opens your favourite AI with this page, ready to explain every loop step by step.

Authored by

Ghanendra Yadav runs Pattern Programs from Bangalore, India. The site started in 2020 to help students practise loops and logic through pattern programs in C, C++, Java and Python. Every program published here is compiled and run before it goes live, and the output shown is the real output.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.