Home / Programs / C# Program to Print Alphabet Triangle
🚀 Programming Example

C# Program to Print Alphabet Triangle

👁 633 Views
💻 Practical Program
📘 Step Learning

There are different triangles that can be printed. Triangles can be generated by alphabets or numbers. In this C# program, we are going to print alphabet triangles.

Let's see the C# example to print alphabet triangle.

💻 Program Code

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';      
       }      
   }  
  }  
                        

🖥 Program Output

     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA
                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.