How to print Pyramid Pattern in C# ?

0 votes
35 views
Sanat Shukla asked 21 days ago in Technology by Sanat Shukla


1 Answer

0 votes
Sanat Shukla answered 21 days ago by Sanat Shukla

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();
        }
     }
  }