📚Intermediate

Print 180° Rotation of Simple Pyramid

Print rotated pyramid

This is a 180° rotated pyramid - a right-aligned triangle where stars are printed from right to left with leading spaces.

Pattern Preview (5 rows):

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

C Program to Print 180° Rotated Pyramid

pyramid_180.c
C
1#include <stdio.h>
2
3int main() {
4 int rows;
5
6 printf("Enter number of rows: ");
7 scanf("%d", &rows);
8
9 for (int i = 1; i <= rows; i++) {
10 // Print spaces (decreasing)
11 for (int j = 1; j <= rows - i; j++) {
12 printf(" ");
13 }
14 // Print stars (increasing)
15 for (int k = 1; k <= i; k++) {
16 printf("*");
17 }
18 printf("\n");
19 }
20
21 return 0;
22}
Output

Enter number of rows: 5

*

**

***

****

*****

💡 Key Insight

For row i: Print (rows - i) spaces, then i stars

🎯 Key Takeaways

Spaces = rows - current row
Stars = current row number

Want to Learn More?

Explore our comprehensive tutorials for in-depth explanations of C programming concepts.

Browse Tutorials
Back to All Examples