Print Inverted Full Pyramid Pattern in C / C++ / Java / Python / C#

Full inverted pyramid pattern

Programs to print the inverted full pyramid pattern have been given here. The number of rows of the pattern is taken as input.






1. Program & output to print the inverted full pyramid pattern




1.1. C Program & output to print the inverted full pyramid pattern

Code has been copied
/*******************************
  	alphabetacoder.com
C program to print the inverted 
full pyramid pattern using *
********************************/

#include <stdio.h>

int main() {
    // declare variables
    int row, i, j;

    // take input
    printf("Enter the number of rows: ");
    scanf("%d", & row);

    // new line
    printf("\n");

    // display the pattern
    for (i = row; i >= 1; i--) {
        // print spaces
        for (j = 1; j <= row - i; j++) {
            printf(" ");
        }
        // print *
        for (j = 1; j <= (2 * i - 1); j++) {
            printf("*");
        }
        // new line
        printf("\n");
    }

    return 0;
}

Output


Enter the number of rows: 8


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

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

  ***********

   *********

    *******

     *****

      ***

       *




1.2. C++ Program & output to print the inverted full pyramid pattern

Code has been copied
/*********************************
  	alphabetacoder.com
C++ program to print the inverted 
full pyramid pattern using *
**********************************/

#include <iostream>

using namespace std;

int main() {
    // declare variables
    int row, i, j;

    // take input
    cout << "Enter the number of rows: ";
    cin >> row;

    // new line
    cout << endl;

    // display the pattern
    for (i = row; i >= 1; i--) {
        // print spaces
        for (j = 1; j <= row - i; j++) {
            cout << " ";
        }
        // print *
        for (j = 1; j <= (2 * i - 1); j++) {
            cout << "*";
        }
        // new line
        cout << endl;
    }

    return 0;
}

Output


Enter the number of rows: 6


***********

 *********

  *******

   *****

    ***

     *




1.3. Java Program & output to print the inverted full pyramid pattern

Code has been copied
/**********************************
  	alphabetacoder.com
Java program to print the inverted 
full pyramid pattern using *
***********************************/

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        // declare instance of Scanner class
        Scanner sc = new Scanner(System.in);
        // declare variables
        int row, i, j;

        // take input 
        System.out.print("Enter the number of rows: ");
        row = sc.nextInt();

        // new line
        System.out.println("");

        // display the pattern
        for (i = row; i >= 1; i--) {
            // print spaces
            for (j = 1; j <= row - i; j++) {
                System.out.print(" ");
            }
            // print *
            for (j = 1; j <= (2 * i - 1); j++) {
                System.out.print("*");
            }
            // new line
            System.out.println("");
        }
    }
}

Output


Enter the number of rows: 4


*******

 *****

  ***

   *




1.4. Python Program & output to print the inverted full pyramid pattern

Code has been copied
#*************************************
#  	alphabetacoder.com
#Python program to print the inverted 
#full pyramid pattern using *
#*************************************

# take input
row = int(input("Enter the number of rows: "))

# new line
print("")

# display the pattern
for i in range(row, 0, -1):
    # print spaces
    for j in range(1, row - i + 1):
        print(" ", end = "")
    # print *
    for j in range(1, 2 * i):
        print("*", end = "")
    # new line
    print("")

Output


Enter the number of rows: 2


***

 *




1.5. C# Program & output to print the inverted full pyramid pattern

Code has been copied
/********************************
  	alphabetacoder.com
C# program to print the inverted 
full pyramid pattern using *
*********************************/

using System;

namespace InvertedFullPyramid {
    class Program {
        static void Main(string[] args) {
            // declare variables
            int row, i, j;

            // take input
            Console.Write("Enter the number of rows: ");
            row = Convert.ToInt32(Console.ReadLine());

            // new line
            Console.WriteLine("");

            // display the pattern
            for (i = row; i >= 1; i--) {
                // print spaces
                for (j = 1; j <= row - i; j++) {
                    Console.Write(" ");
                }
                // print *
                for (j = 1; j <= (2 * i - 1); j++) {
                    Console.Write("*");
                }
                // new line
                Console.WriteLine("");
            }

            // wait for user to press any key
            Console.ReadKey();
        }
    }
}

Output


Enter the number of rows: 10


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

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

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

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

    ***********

     *********

      *******

       *****

        ***

         *