C# Program to Print Alphabet Triangle

C# Programming Language Loop control in C# Language (Article) Loop control in C# Language (Program)

564

Program:

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:

     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C# Programming Language. Then you can visit below links to get more depth on this subject.