#include <stdio.h>
int main() {
int rows;
char current = 'A';
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
printf("%c ", current);
current++;
}
printf("\n");
}
return 0;
}
Enter the number of rows: 6
A
B C
D E F
G H I J
K L M N O
P Q R S T U
rows
in the triangle, and current to store the current
alphabet character to be printed.printf
and scanf
.for
loops to print the triangle. The outer loop controls the number of rows in the triangle, and the inner loop controls the number of characters to be printed in each row.printf
and then increment current
to print the next character in the next iteration of the loop.printf
to move to the next row of the triangle.