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=1; i<=n; i++)
{
//Prints trailing spaces before star gets printed
for(j=1; j<i; j++)
{
printf(" ");
}
//Prints hollow inverted right triangle
for(j=i; j<=n; j++)
{
if(j==i || j==n || i==1)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Related Posts :
- Back to Home »
- Star Patterns »
- 42.Hollow Mirrored Inverted Right Rriangle using *'s as shown below.