C Program to print Hollow Square in a star pattern
Program
/* Hollow Square */
#include <stdio.h>
void main()
{
int i, j, n;
printf("Enter total rows:\t");
scanf("%d", &n);
for(i = 1; i <= n; i++)
{
for(j = 1; j <= n; j++)
{
if(i == 1 || i == n || j == 1 || j == n)
printf("*");
else
printf(" ");
}
printf("\n");
}
}
Output
Enter total rows: 5
*****
* *
* *
* *
*****