Inverted Right triangle star pattern program

Inverted Right triangle star pattern in c

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

Output

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

Inverted Right triangle star pattern in c++

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

Output

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

Inverted Right triangle star pattern in c#

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

namespace InvertedRightTriangleStarPatternProject
{
    class InvertedRightTriangleStarPattern
    {
        public void Show(int input)
        {
            for (int i = 0; i < input; i++)
            {
                for (int j = input; j > i; j--)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            InvertedRightTriangleStarPattern i = new InvertedRightTriangleStarPattern();
            Console.WriteLine("Enter the number of rows");
            int input = Convert.ToInt32(Console.ReadLine());
            i.Show(input);
            Console.ReadLine();
        }
    }
}

Output

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

Inverted Right Triangle star pattern in java

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

Output

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

Write a comment


Name Email Message