Facebook Pixel

Why is my pyramid skewed to the right?

You either miscalculated the space formula, or you are adding extra spaces after the stars, which pushes the subsequent newlines out of alignment.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Printing a Pyramid Star Pattern (Spaces and Stars)

Because you must print a specific, mathematically decreasing number of invisible space characters before you can print the mathematically increasing stars.

No. They are placed sequentially (one after the other) inside the outer loop. The space loop finishes completely before the star loop begins.

If N is the total height and 'row' is the current row, the formula for leading spaces is N - row.

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.