# Thread: Help making a hollow rectangle with thickness border

1. Originally Posted by Adak
Oh that must be a lie - noobs tell us "it doesn't work", all the time!!
Using the logic formula produced the second piece of code I posted there and it does not produce boxes.

2. So where are you printing the spaces?
Code:
```for each row
for each column
if row < thickness, print a wall
if row > box size - thickness, print a wall
if col < thickness, print a wall
if col > box size - thickness, print a wall
otherwise, print a space
print newline```
Quzah.

3. Originally Posted by quzah
So where are you printing the spaces?
Code:
```for each row
for each column
if row < thickness, print a wall
if row > box size - thickness, print a wall
if col < thickness, print a wall
if col > box size - thickness, print a wall
otherwise, print a space
print newline```
Quzah.
Does my else function not make sense where it is then?

4. I'm going to give a tip.
Let's start simple. Let width = 10, height = 10, thickness = 2.
Now let the console be a coordinate system with origin in the upper-left corner.
Let's see if you can follow me here.
Row zero. We print stars all the way.
Row one. We print stars all the way.
Row two. We print two stars, 6 spaces, then 2 stars. Right?
Repeat this for row 3-7.
Now repeat row 0-1 and we're done.

Let's try to generalize it.
If row is 0 or 1 OR row > is 8 or 9, always print a star for every column.
If row 2...7 AND column is 0 or 1 or 8 or 9, print a star.
Else, print a space.

Try implementing that first and the generalizing it to given values.

5. Elysia i would like to thank you. your logic helped a lot kinda feel bad that it took me this long to see it and how easy it seems now that i finally got it.
this is what i got

Code:
```for(row = 0; row < height; row++)
{
for(column = 0; column < width; column++)
{

if(row < thickness)
{
printf("*");   //prints top part
}
if(row >= (height - thickness))
{
printf("*");   // prints bottom part
}
if(row >= thickness && row < (height - thickness) && column < thickness)
{
printf("*");
}
if(row >= thickness && row < (height - thickness) && column > thickness && column <=(width - thickness))
{
printf(" ");
}
if(row >= thickness && row < (height - thickness) && column >=(width - thickness))
{
printf("*");
}```

Popular pages Recent additions