All Type Coding

Search Here

How to printing a reverse triangle in c#

using System;
class abc
{
    int n, j;
    public void fun()
    {
        Console.WriteLine("enter the number of rows : ");
        n = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("pattern is : ");
        Console.WriteLine("----------");
        for (int i = n; i > 0; i--)
        {
            for (j = n - i; j > 0; j--)
            {
                Console.Write(" ");
            }
            for (j = (2 * i) - 1; j > 0; j--)
            {
                Console.Write("*");
            }
            Console.Write("\n");
        }
        Console.ReadKey();
    }
}
class pat5
{
    public static void Main(string[] args)
    {
        abc a = new abc();
        a.fun();
    }
}


1 comment :

  1. informative blog , keep posting and if you are intresting in code developer then checkout python course in pune

    ReplyDelete