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 number of rows : ");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
//Prints trailing spaces
for(j=i; j<n; j++)
{
printf(" ");
}
//Prints hollow right triangle
for(j=1; j<=i; j++)
{
if(i==n || j==1 || j==i)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Related Posts :
- Back to Home »
- Star Patterns »
- 40.Hollow Mirrored Right Triangle using *'s as shown below.