In the incremental alphabet triangle each row starts one letter later than the row above and then counts forward: A, B C, C D E, D E F G. The last letter of each row goes up two at a time: A, C, E, G, I.
Quick answer: Row i prints i letters starting at the i-th letter. So the letter at position j is 'A' + i + j − 2. The last letter of row i is the (2i − 1)-th letter of the alphabet.
This program is part of the String Patterns collection.
Table of contents8 sections
Incremental Alphabet Triangle output
Output (n = 5):
A B C C D E D E F G E F G H I

Same shape, other characters: the 0-1 (Binary) Triangle, Alphabet Triangle, Descending Alphabet Triangle, Hash (#) Right 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 incremental alphabet triangle works
Both counters move the letter forward: the row sets the start and the position walks along from there. That is why the start rises by one per row while the end rises by two. The number version of the same idea is the stepped number triangle (1, 23, 345).
- Run the outer loop for
ifrom1ton, one row per pass. - Print
iletters (letter numberi + j − 1). - Move to the next line.
Key takeaways
- Each row starts at its own letter and counts forward.
- The last letter is letter
2i − 1: A, C, E, G, I. - Letters repeat down the diagonals from top left to bottom right.
- Thirteen rows would end at Y; fourteen would run past Z.
Incremental 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;
}Incremental 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;
}Incremental Alphabet Triangle in Java
public class IncrementalAlphabetTriangle {
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();
}
}
}Incremental 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
What is the difference from the continuous alphabet triangle?
In a continuous triangle the letters never repeat: A, B C, D E F. Here each row restarts one letter after the previous start, so C appears on rows 2 and 3.
How do I right-align it?
Print n − i double spaces before each row; each letter plus its space takes two characters.
How do I let the user choose the number of rows?
Read n from the keyboard instead of fixing it in the code: scanf("%d", &n); in C, cin >> n; in C++, new Scanner(System.in).nextInt() in Java and int(input()) in Python.






