Pyramid Program

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6.   
  7. namespace Pyramid  
  8. {  
  9.     class Program  
  10.     {  
  11.         public static void print(int no)  
  12.         {  
  13.   
  14.             for (int i = 1; i <= no; i++)  
  15.             {  
  16.   
  17.                 for (int j = i; j <= no; j++)  
  18.                 {  
  19.                     Console.Write("  ");  
  20.   
  21.                 }  
  22.   
  23.                 for (int k = 1; k <= 2 * i - 1; k++)  
  24.                 {  
  25.                     Console.Write("*" + " ");  
  26.                 }  
  27.                 Console.WriteLine();  
  28.             }  
  29.   
  30.             Console.ReadLine();  
  31.   
  32.         }  
  33.   
  34.         static void Main(string[] args)  
  35.         {  
  36.   
  37.             Console.WriteLine("Enter the number of rows for the output");  
  38.             int r = Convert.ToInt32(Console.ReadLine());  
  39.             print(r);  
  40.         }  
  41.   
  42.     }  
  43. }