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..