How to print Pyramid Pattern in C# ?

Asked 03-Sep-2018
Viewed 1248 times

1 Answer


0

How to print Pyramid Pattern in C# ?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
             int x = 15; // Total Number of Lines...
             for (int i = 1; i<= x; i++)
              {
                 //loop to print spaces
                 for (int j = 1; j <= (x - i); j++)
                    Console.Write(" ");
                 //loop to print stars
                for (int t = 1; t <i * 2; t++)
                   Console.Write("*");
                Console.WriteLine();
              }
           Console.ReadLine();
        }
     }
  }

How to print Pyramid Pattern in C# ?