C Program to print Hollow Right angled Triangle in a pyramid star pattern Type 2

Program

#include<stdio.h>
void main()
{
    int i, j, rows;
    printf("Enter number of rows : ");
    scanf("%d", &rows);
    for(i = 1; i <= rows; i++)
    {
        for(j = i; j < rows; j++)
        {
            printf(" ");
        }
        for(j = 1; j <= i; j++)
        {
            if(i == rows || j == 1 || j == i)
            {
                printf("*");
            }
            else
            {
                printf(" ");
            }
        }
        printf("\n");
    }
}

Output

Enter number of rows : 5
    *
   **
  * *
 *  *
*****