C Program to Print Character Pattern - Source Code, Output & Execution Flow

C Program to Print Character Pattern

This C program prints a character triangle pattern using nested loops.

#include <stdio.h>
int main() {
    int rows, i, j;
    char ch = 'A';
    printf("Enter number of rows: ");
    scanf("%d", &rows);
    for (i = 1; i <= rows; i++) {
        for (j = 1; j <= i; j++) {
            printf("%c ", ch);
        }
        ch++;
        printf("
");
    }
    return 0;
}
Enter number of rows: 5
A 
B B 
C C C 
D D D D 
E E E E E

In this program, the input is read first when required, the core logic is applied step by step, and the final result is displayed using printf(). Follow the execution flow beside the code to understand how each statement contributes to the output.