How to Print Alphabet Triangle in C# ?

0 votes
42 views
Rahul Ahuja asked 05-Sep-2018 in Technology by Rahul Ahuja

1 Answer

0 votes
Sanat Shukla answered 05-Sep-2018 by Sanat Shukla
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# ?