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);
//Outer loop for iterating over rows
for(i=1; i<=n; i++)
{
for(j=i; j<=n; j++)
{
/*
* Stars gets printed only for row=1, column=1 or column=n
*/
if(i==1 || j==i || j==n)
{
printf("*");
}
else
{
//Print spaces if stars don't get printed
printf(" ");
}
}
printf("\n");
}
return 0;
}
**********OUTPUT**********
Related Posts :
- Back to Home »
- Star Patterns »
- 41.Hollow Inverted Right Triangle using *'s as shown below.