Sunday, November 15, 2020

Write the C# program for the following pattern

 

 class Program
    {
        static void Main(string[] args)
        {
            int n = 5;
            int space;
            for (int i = 1; i <= n; i++)
            {
                for (space = 1; space <= (n - i); space++)
                {
                    Console.Write(" ");
                }
                for (int j = 1; j <= i; j++)
                {
                    Console.Write(j);
                }
                for (var k = (i - 1); k >= 1; k--)
                {
                    Console.Write(k);
                }
                Console.WriteLine();
            }
        }
    }



No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...