How to Print Alphabet Triangle in C# ?

Asked 05-Sep-2018
Viewed 545 times

1 Answer


0

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        public static void Main(string[] args)
        {
            char ch = 'A';
            int i, j, k, m;
            for (i = 1; i <= 7; 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.ReadLine();
        }
    }
}

How to Print Alphabet Triangle in C# ?