#Day 5 :101 Days Pyramid Pattern in C# .NET

Day 5: Creating an Alphabet Pyramid Pattern in C#

In today's post, we will explore how to create an alphabet pyramid pattern using C#. 

This pattern involves printing a sequence of alphabets in an increasing manner, where each row adds one more character than the previous one.

 The resulting pattern looks like this:

a

a b

a b c

a b c d

a b c d e


We will use nested loops in C# to generate this pattern. 

The outer loop controls the number of rows, and the inner loop prints the characters for each row.

 This is a great exercise for beginners to understand nested loops and character manipulation in C#.


Source Code :


using System;

namespace Pyramid

{

    internal class Program

    {

        static void Main(string[] args)

        {

            int n = 102;


            for(int i = 97; i <= n; i++)

            {

                for(int j=97;j<=i;j++)

                {

                    Console.Write((char)j);

                }

                Console.WriteLine();

            }

            Console.Read();

        }

    }

}


OutPut:




No comments:

Post a Comment