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=1; j<i; j++)
{
printf(" ");
}
//Prints the hollow square
for(j=1; j<=n; j++)
{
if(i==1 || j==1 || i==n || j==n)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Related Posts :
- Back to Home »
- Star Patterns »
- 38.Hollow Mirrored Rhombus using *'s as shown below.