Hacker Challenge: Printing a Star Pattern 2

Printing a star pattern using nested loops

In this lesson, we’ll look at another approach to creating the star pattern.

Problem statement

Write a program that takes the height (has to be a multiple of 4) as the input from the user and prints a star, as the shown below. The following shape is of height 12:

        *
       ***
      *****
*****************
 ***************
  *************
  *************
 ***************
*****************
      *****
       ***
        *
         

Get hands-on with 1200+ tech skills courses.