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

Program

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

Output

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