May 27, 2020

How to printing 1 121 12321 in triangle in C#.

How to display 1 121 12321 in triangle in C#.

In this article, we will learn how to display 1 121 12321 in triangle below pattern in c#.

How to display 1 121 12321 in triangle in C#.

Sample Solution

C# Sharp Code

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

namespace ConsoleApplication1
{
    class program
    {
        static void Main(string[] args)
        {
            int numberoflayer, space, number;
            Console.WriteLine("Enter Number ");
            numberoflayer = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("print parmid");
            for (int i = 1; i <= numberoflayer; i++)
            {
            for (space = 1; space <= (numberoflayer - i); space++)

             Console.Write(" ");
            for (number = 1; number <= i; number++)

             Console.Write(number);
            for (number = i - 1; number >= 1; number--)

                Console.Write(number);
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

                                                                   Sample Output

How to printing 1 121 12321 in triangle in C#.


No comments:

Post a Comment