Open In App

C Program For Printing 180 Degree Rotation of Simple Half Left Pyramid

Last Updated : 30 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The 180° Rotation of a Simple Half Left Pyramid is a pattern where the base of the pyramid is aligned with the bottom, and the entire structure appears rotated by 180°. The resulting structure is nothing but inverted right half pyramid. In this article, we will learn how to print the 180° Rotated Half Left Pyramid using a C program.

180-rotated-left-half-pyramid
Star Pattern
#include <stdio.h>

int main() {
    int n = 5;

    // Outer loop to print all rows
    for (int i = 0; i < n; i++) {

        // Inner loop to print the * in each row
        for (int j = 0; j < n - i; j++)
            printf("* ");
        printf("\n");
    }
}
Number Pattern
#include <stdio.h>

int main() {
    int n = 5;

    // Outer loop to print all rows
    for (int i = 0; i < n; i++) {

        // Inner loop to print the numbers in each row
        for (int j = 0; j < n - i; j++)
            printf("%d ", j + 1);
        printf("\n");
    }
}
Alphabet Pattern
#include <stdio.h>

int main() {
    int n = 5;

    // Outer loop to print all rows
    for (int i = 0; i < n; i++) {

        // Inner loop to print alphabets in each row
        for (int j = 0; j < n - i; j++)
            printf("%c ", j + 'A');
        printf("\n");
    }
}


Output

* * * * *   |   1 2 3 4 5   |   A B C D E 
* * * * | 1 2 3 4 | A B C D
* * * | 1 2 3 | A B C
* * | 1 2 | A B
* | 1 | A

Explanation:

  • The outer loop runs from i = 1 to i = n printing the rows of the pyramid.
  • For the current row i, the number of stars is n - i, where n is the total number of rows. It is printed by inner loop.

Next Article

Similar Reads