Number Triangle in C Sharp

Number Triangle

There are several ways to print a number triangle in C#.

Example:

using System;  
  public class Example  
   {  
     public static void Main(string[] args)  
      {  
       int  x, y, z, w, num;           
       Console.Write("Enter the Range: ");    
       num = int.Parse(Console.ReadLine());     
       for(x=1; x<=num; x++)      
       {          
        for(y=1; y<=num-x; y++)      
        {      
         Console.Write(" ");      
        }      
        for(z=1; z<=x; z++)      
        {      
         Console.Write(z);      
        }      
        for(w=x-1; w>=1; w--)      
        {      
        Console.Write(w);      
        }      
        Console.Write("\n");      
       }       
   }  
  }

Output:

Explanation:

In the above example, we are printing a number triangle.

Please Share