/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
int main()
{
int i, j, rows;
printf("Enter number of rows : ");
scanf("%d", &rows);
for(i=1; i<=rows; i++)
{
/* Print trailing spaces */
for(j=i; j<rows; j++)
{
printf(" ");
}
/* Print hollow pyramid */
for(j=1; j<=(2*i-1); j++)
{
/*
* Print star for last row (i==rows),
* first column(j==1) and for
* last column (j==(2*i-1)).
*/
if(i==rows || j==1 || j==(2*i-1))
{
printf("*");
}
else
{
printf(" ");
}
}
/* Move to next line */
printf("\n");
}
return 0;
}