Posted by : Unknown
Wednesday, February 3, 2016
Ans:
#include <stdio.h>
int main()
{
int i, j, n;
//Reads number of rows to be printed from user
printf("Enter value of n : ");
scanf("%d", &n);
for(i=n; i>=1; i--)
{
//Prints trailing spaces
for(j=i; j<n; j++)
{
printf(" ");
}
//Prints hollow pyramid
for(j=1; j<=(2*i-1); j++)
{
if(i==n || j==1 || j==(2*i-1))
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Related Posts :
- Back to Home »
- Star Patterns »
- 44. Hollow Inverted Pyramid using *'s as shown below.