# Thread: draw an empty square of asterisks

1. ## draw an empty square of asterisks

Hi everyone, im new to C and I'm stuck doing an exercise that asks me to draw an empty square of " * " using "while" and where n = side (side must be >=1 and <= 20) I succeeded to make a square of asterisks like this:
Code:
```n = 6
******
******
******
******
******
******```
now i need to do the same thing but the box needs to be empty:
Code:
```n = 6
******
*    *
*    *
*    *
*    *
******```
This is the code i wrote for the first exercise:
Code:
```#include <stdio.h>
int main()
{
int n, i, j;

printf("Insert a number between 1 and 20:\n");
scanf("%d", &n);

if ((n >= 1)&&(n <=20))
{
i = 0;
while( i<n )
{
i++;
j = 0;
while( j<n )
{
printf("* ") ;
j++;
}
printf("\n");
}
}
else
printf("the square's side must be between 1 and 20.\n");

return 0;
}```
Any help would be appreciate, I know this should be easy to do but im still a beginner..

while (j < n)
if (j == 1)
print asterisk

Now combine the left and right border (which are the only places you need to print up an asterisk, into one if statement:

if( j == left border || j == right border)
print asterisk

3. same like my assignment lastweek.. hahaha..
if you look the combination
Code:
```if N=5
1 2 3 4 5
1* * * * *
2*        *
3*        *
4*        *
5* * * * *```
the number is up to you(when you start, 0 or 1 at for)
row one, row five, column 1, and column 5, else print space...
hehehe.. hope you get the way...

4. I solved it:
Code:
```#include <stdio.h>
int main()

{
int n, i, j, f;

printf("Insert a number (1-20):\n");
scanf("%d", &n);

if ((n >= 1)&&(n <=20))
{

i = 0;
while(i < n)
{
i++;
j = 0;
while(j <= n)
{

if (((j > 1)&&(j < n))&&((i > 1)&&(i < n)))
{
printf("  ");
}
else if((j !=0 )&&(i!=0))
{
printf("* ");
}

j++;
}
printf("\n");

}
}
else
printf("the number must be between 1 and 20.\n");

return 0;
}```

Thanks for the help ;D