Skip to content
C

Star Pyramid Pattern

Mediumpython

Print a centered pyramid of stars with the given number of rows, using nested loops.

Example for 4 rows:

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

Approach: for row i (starting at 1), print (rows - i) leading spaces followed by (2*i - 1) stars.

Input: One line: the number of rows (a whole number).

Output: rows lines forming a centered star pyramid, as shown above.

Input (stdin)

Output

Run your code to see output here...