C# Program to Print Alphabet Triangle

In this post, we will learn about C# Program to Print Alphabet Triangle with an example.

Description:

In my previous posts I have explained various topics like Get site visitor count in asp.net
Convert generic list to datatable in Asp.Net C#.Net, Abstract Class in C# with Example,
Routing in Asp.Net MVC with Example
,Use of Global.asax in Asp.net



Now in this post, I will explain C# Program to Print Alphabet Triangle with appropriate example. There are different type of triangles that can be printed. Triangles can be generated by alphabets ,numbers or any other special character. In this C# program, we are going to print alphabet triangles.
Create Console Application in Visual Studio and write below lines of code in it.

using System;
namespace DotNetK
{
    class Program
    {
        static void Main(string[] args)
        {
            // C# Program to Print Alphabet Triangle

            char _ch = 'A';
            int i, j, k, m;
            for (i = 1; i <= 4; 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';
            }               

            Console.ReadKey(); // To hold the console screen.
        }
    }
}

Output

A
ABA
ABCBA
ABCDCBA


Read :

Summary

You can also read about ASP.NET, C#.Net, JQUERY, AJAX, JavaScript
I hope you get an idea about C# Program to Print Alphabet Triangle.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you liked this post, don’t forget to share this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website