#include <stdio.h>

int main() {
    int n, i, j;

    printf("Enter the number of rows for the triangle: ");
    scanf("%d", &n);

    for (i = 1; i <= n; i++) {
        // Print spaces to align the asterisks to form a triangle
        for (j = 1; j <= n - i; j++) {
            printf(" ");
        }

        // Print asterisks for the current row
        for (j = 1; j <= 2 * i - 1; j++) {
            printf("*");
        }

        // Move to the next line to start the next row
        printf("\n");
    }

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: