Hollow Pyramid Pattern

Princy Prakash
May 25, 2023

--

ALGORITHM:

  1. Get the input value n, which represents the number of rows in the hollow pyramid.
  2. Initialize two loops: an outer loop for rows, i from 0 to n-1, and an inner loop for columns, j from 0 to n-1.
  3. Repeat the following steps until i reaches n:

a. Check if j is equal to n-i . If true, print a space (" ").

b. Repeat the following steps until j reaches 2*i+1:

  • Check if i is equal to 0 or j is equal to 0 or j is equal to 2*i or i is equal to n-1 . If true, print an asterisk ("*"). Otherwise, print a space (" ").
  • Increment j by 1.

c. Move to the next line.

d. Increment i by 1.

4. After the loops complete, the hollow pyramid pattern will be printed.

FLOWCHART:

--

--

Princy Prakash
Princy Prakash

Written by Princy Prakash

Hi I Am Princy. I recently discovered my passion for programming and excited to get deeper into the world of technologies also in problem-solving

No responses yet