C Online Compiler
Example: Right-Angled Star Triangle
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Right-Angled Star Triangle #include
int main() { int i, j, rows = 5; // Step 1: Outer loop for rows for (i = 1; i <= rows; i++) { // Step 2: Inner loop for columns (stars in each row) // Prints 'i' number of stars in the i-th row for (j = 1; j <= i; j++) { printf("*"); } // Step 3: Newline after each row printf("\n"); } return 0; }
Output
Clear
ADVERTISEMENTS