C Alphabet Pattern Programs

Beginner
6 min read
Updated: Nov 2026
3 examples
char + printf

Definition and Usage

A C alphabet pattern is a program that prints letters in rows. The outer for loop chooses the row. The inner for loop prints each char with printf("%c", letter), then printf("\n") ends that row.

In C, char is an integer type. letter++ walks A, B, C… and 'A' + col is an int. printf with %c prints that code as a character, so you do not cast it first.

One row, two calls.

printf("%c", letter) stays on the line. printf("\n") runs once after the inner loop and starts the next row.

C Syntax

The same three pieces show up in every program below: a row loop, a char, and printf.

C
for (int row = 1; row <= rows; row++) {
    char letter = 'A';
    for (int col = 1; col <= row; col++) {
        printf("%c", letter);   /* same line */
        letter++;                /* next char */
    }
    printf("\n");                /* end the row */
}

How C Prints a Letter

Map each part of the console shape to a C type or call.

PieceCWhat it does
Letterchar letter = 'A';Integer code you can increment
Next letterletter++A becomes B on the same row
Jumpprintf("%c", 'A' + col);%c prints the int sum as a character
Same lineprintf("%c", letter);No newline between letters
New rowprintf("\n");Finish the row
Indentprintf(" ");Leading spaces for pyramids
One characterputchar(letter);Same letter, no format string

C Examples

Three programs. Each one changes only the C that picks the letter or the space.

Example 1 — Grow a row with char++

Restart at 'A' on every row, then increment inside the inner loop.

C
#include <stdio.h>

int main(void) {
    int rows = 5;

    for (int row = 1; row <= rows; row++) {
        char letter = 'A';
        for (int col = 1; col <= row; col++) {
            printf("%c", letter);
            letter++;
        }
        printf("\n");
    }
    return 0;
}

How It Works

  1. The outer for sets how many letters this row prints.
  2. char letter = 'A' starts every row at A.
  3. letter++ advances the char; printf("\n") ends the row.

Example 2 — Pick the letter with 'A' + col

Skip the running char. %c prints the integer sum.

C
#include <stdio.h>

int main(void) {
    int rows = 4;

    for (int row = 0; row < rows; row++) {
        for (int col = 0; col <= row; col++)
            printf("%c", 'A' + col);
        printf("\n");
    }
    return 0;
}

How It Works

  1. 'A' + col is an int, not a stored char.
  2. %c prints that integer as a character. No cast is required.
  3. Column 0 is A, column 1 is B, and so on.

Example 3 — Indent with printf(" ")

Print spaces before the letters so the triangle sits on the right. putchar writes each letter.

C
#include <stdio.h>

int main(void) {
    int rows = 4;

    for (int row = 1; row <= rows; row++) {
        for (int space = 1; space <= rows - row; space++)
            printf(" ");

        for (int col = 0; col < row; col++)
            putchar('A' + col);

        printf("\n");
    }
    return 0;
}

How It Works

  1. The first inner loop prints rows - row spaces.
  2. putchar('A' + col) writes one character and needs no format string.
  3. Fewer spaces and more letters on each later row pull the shape right.

34 C Alphabet Pattern Programs

Each card is a full C program: nested for loops, char arithmetic, and printf("%c", ...). Open one for the walkthrough.

Alphabet Pattern 1
Alphabet Pattern 2
Alphabet Pattern 3
Alphabet Pattern 4
Alphabet Pattern 5
Alphabet Pattern 6
Alphabet Pattern 7
Alphabet Pattern 8
Alphabet Pattern 9
Alphabet Pattern 10
Alphabet Pattern 11
Alphabet Pattern 12
Alphabet Pattern 13
Alphabet Pattern 14
Alphabet Pattern 15
Alphabet Pattern 16
Alphabet Pattern 17
Alphabet Pattern 18
Alphabet Pattern 19
Alphabet Pattern 20
Alphabet Pattern 21
Alphabet Pattern 22
Alphabet Pattern 23
Alphabet Pattern 24
Alphabet Pattern 25
Alphabet Pattern 26
Alphabet Pattern 27
Alphabet Pattern 28
Alphabet Pattern 29
Alphabet Pattern 30
Alphabet Pattern 31
Alphabet Pattern 32
Alphabet Pattern 33
Alphabet Pattern 34

Frequently Asked Questions

A char is an integer type. letter++ advances one letter, and 'A' + offset jumps to a specific letter. printf("%c", letter) prints that code as a character. %c already expects an int, so no cast is required.
printf("%c", letter) prints one character and stays on the same line. printf("\n") ends the row. Call it once after the inner loop. putchar('\n') does the same row break.
Character arithmetic continues past Z into other codes. For A–Z demos, keep rows between 1 and 26. Check scanf: if (scanf("%d", &rows) != 1) the input was not an int.
Yes. putchar(letter) writes one character and does not need a format string. printf("%c", letter) is the same letter with a format. Nested loops are the skill these programs teach; putchar is the shorter call.

Next: Alphabet Pattern 1

A full C walkthrough of the right-angled letter triangle, from 'A' through printf("\n").

Alphabet Pattern 1 →

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.

28 people found this page helpful