Print out unlimited squares from ascii char.

Hi i want to make software that print out unlimited squares from * at sides and . in middle.
I have code here to print only one square from input number that defines size how do i make when there will be more input numbers ? thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 int main()
{
  int n,j,i;
 scanf("%d",&n);
  
for(i = 0; i < n; i++)
	{
		for(j = 0; j < n; j++)
			if (i==0||i==n-1||j==0||j==n-1)
				printf("*");
			else
				printf(".");
		printf("\n");
	
  }
  return 0;
}
Last edited on
First I would put the code to print the square in a separate function - void PrintSquare(short NumStars)

In the main program you ask for the number of squares and the number of stars. Then you need a loop to call the function PrintStars the required number of times.
Topic archived. No new replies allowed.