C Online Compiler
Example: Inverted Right-Angled Star Triangle
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Inverted Right-Angled Star Triangle #include
int main() { int i, j, rows = 5; // Step 1: Outer loop for rows for (i = rows; i >= 1; i--) { // Start from max rows, decrement // 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