Facebook Pixel

How do I make a hollow rectangle?

The logic is identical, just replace 'row == n' with 'row == height' and 'col == n' with 'col == width'.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Printing a Hollow Square Star Pattern

Generate an N x N grid and print a star only if the current row or column is at the absolute boundary (1 or N). Otherwise, print a space.

You could, but it is incredibly messy. Coordinate-based boolean logic is the standard and most readable way to handle hollow shapes.

Because terminal fonts are usually taller than they are wide. A star (*) takes up more vertical space than horizontal space. You can fix this by printing '* ' (with a space) to widen the shape.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.