Problem Solving: Hollow Patterns

Learn how to print hollow shapes. We will first print the hollow rectangle and then several hollow rectangles.

In this lesson, we will use nested loops to print hollow shapes. So let’s start with a hollow rectangle.

Hollow rectangle

Let’s write a program that prints the following shape.

Height: 6
Width : 20 
********************
*                  *
*                  *
*                  *
*                  *
********************

Let’s make the pattern table first then we will analyze how to implement it.

Get hands-on with 1200+ tech skills courses.