C# Program To Print Alphabet Triangle

There are various types of triangles that can be displayed. Triangles can be produced using letters or digits. In this C# script, we will be generating triangles using alphabets.

Let's explore an example in C# to generate a triangle of alphabets.

Example

Example

using System;

  public class PrintExample

   {

     public static void Main(string[] args)

      {

       char ch='A';    

       int i, j, k, m;    

       for(i=1; i<=5; i++)    

       {    

        for(j=5; j>=i; j--)    

         Console.Write(" ");    

        for(k=1;k<=i;k++)    

         Console.Write(ch++);    

        ch--;    

        for(m=1;m<i;m++)    

         Console.Write(--ch);    

        Console.Write("\n");    

        ch='A';    

       }    

   }

  }

Output:

Output

A

    ABA

   ABCBA

  ABCDCBA

 ABCDEDCBA

Input Required

This code uses input(). Please provide values below: