C Online Compiler
Example: Right-Angled Alphabet Triangle (Row Repetition)
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Right-Angled Alphabet Triangle (Row Repetition) #include
int main() { int i, j, rows = 5; char ch; // Step 1: Outer loop for rows for (i = 1; i <= rows; i++) { // Step 2: Calculate the character for the current row ch = 'A' + i - 1; // Step 3: Inner loop for columns for (j = 1; j <= i; j++) { printf("%c ", ch); // Print the row character } // Step 4: Newline after each row printf("\n"); } return 0; }
Output
Clear
ADVERTISEMENTS