Inverted pyramid star pattern program

Inverted pyramid star pattern in c

#include<stdio.h>
#include<conio.h>
void main()
{
	int temp=1,input;
	printf("Enter the number of rows \n");
	scanf("%d",&input);
	for(int i=input;i>=1;i--)
	{
		for(int j=1;j<temp;j++)
		{
			printf(" ");
		}
		for(int k=1;k<=2*i-1;k++)
		{
			printf("*");
		}
		temp++;
		printf("\n");
	}
	getch();
}

Output

Enter the number of rows
4
*******
 *****
  ***
   *

Inverted pyramid star pattern in c++

#include<iostream>
#include<conio.h>
using namespace std;
class InvertedPyramidStarPattern
{
public:
	void Show(int input)
	{
		int temp=1;
		for(int i=input;i>=1;i--)
		{
			for(int j=1;j<temp;j++)
			{
				cout<<" ";
			}
			for(int k=1;k<=2*i-1;k++)
			{
				cout<<"*";
			}
			temp++;
			cout<<"\n";
		}
	}
};
void main()
{
	int input;
	cout<<"Enter the number of rows \n";
	cin>>input;
	InvertedPyramidStarPattern i;
	i.Show(input);
	getch();
}

Output

Enter the number of rows
5
*********
 *******
  *****
   ***
    *

Inverted pyramid star pattern in c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InvertedPyramidStarPatternProgram
{
    class InvertedPyramidStarPattern
    {
        void Show(int input)
        {
            int temp = 1;
            for (int i = input; i >= 1; i--)
            {
                for (int j = 1; j < temp; j++)
                {
                    Console.Write(" ");
                }
                for (int k = 1; k <= 2 * i - 1; k++)
                {
                    Console.Write("*");
                }
                temp++;
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            InvertedPyramidStarPattern p = new InvertedPyramidStarPattern();
            Console.WriteLine("Enter the number of rows");
            int input = Convert.ToInt32(Console.ReadLine());
            p.Show(input);
            Console.ReadLine();
        }
    }
}

Output

Enter the number of rows
6
***********
 *********
  *******
   *****
    ***
     *

Inverted pyramid star pattern in java

import java.util.*;
class InvertedPyramidStarPattern
{
	void Show(int input)
    {
        int temp = 1;
        for (int i = input; i >= 1; i--)
        {
            for (int j = 1; j < temp; j++)
            {
            	System.out.print(" ");
            }
            for (int k = 1; k <= 2 * i - 1; k++)
            {
            	System.out.print("*");
            }
            temp++;
            System.out.println();
        }
    }
}
class examples
{
public static void main(String[] args)
	{
	InvertedPyramidStarPattern p=new InvertedPyramidStarPattern();
	Scanner sc=new Scanner(System.in);
	System.out.println("Enter the number of rows");
	int input=sc.nextInt();
	p.Show(input);
    }
}

Output

Enter the number of rows
7
*************
 ***********
  *********
   *******
    *****
     ***
      * 

Write a comment


Name Email Message