C# Program to print Alphabet Triangle

In this article, I will be writing a C# Program to print an Alphabet triangle. I will explain the program outline and give the output of the C# program.

Program Outline

We may print two sorts of triangles in C#: those created by letters and those generated by numbers. In the C# programming language, I have presented the list of all alphabet pattern programmes.

Algorithm

Here’s the algorithm to print alphabet triangle:

  • STEP 1: START
  • STEP 2: Declare the variables
  • STEP 3: Input number of rows to print
  • STEP 4: Start the parent of loop
  • STEP 5: Now make the child for loop
  • STEP 6: In this child loop print the blank spaces
  • STEP 7: now use another child loop to start drawing Alphabet Pattern
  • STEP 8: Now this for loop will also execute under the parent for loop
  • STEP 9: Print “\n” for changing the line before the increment of the main loop
  • STEP 10: increment of the main for loop
  • STEP 11: return the zero value for main function

C# Program to print Alphabet Triangle

Here’s the C# Program to print Alphabet Triangle:

using System;  
  public class Example  
   {  
     public static void Main(string[] args)  
      {  
       char ch = 'a';      
       int x, y, z, w;      
       for(x=1; x<=5; x++)      
       {      
        for(y=5; y>=x; y--)      
         Console.Write(" ");      
        for(z=1; z<=x; z++)      
         Console.Write(ch++);      
        ch--;      
        for(w=1; w<x; w++)      
         Console.Write(--ch);      
        Console.Write("\n");      
        ch='a';      
       }      
   }  
  }

Output

Here’s the output of the C# Program to print the Alphabet triangle:

     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA

Related Articles

  1. C# Program to check Palindrome number
  2. C# Program to Check Vowels or Consonants
  3. Convert Word to PDF using C# Program
  4. C Program to check whether the person is eligible to vote or not.
  5. C Program to Make a Digital Clock Using C Graphics

Similar Posts

Leave a Reply

Your email address will not be published.