How to print Pyramid Pattern in C# ?

0 votes
53 views
Sanat Shukla asked 03-Sep-2018 in Technology by Sanat Shukla

How to print Pyramid Pattern in C# ?

1 Answer

0 votes
Sanat Shukla answered 03-Sep-2018 by Sanat Shukla

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# ?