Answers for "print pyramid c#"

C#
0

print pyramid c#

Console.WriteLine("sharing prymid length:");
            var prymaidlength = Console.ReadLine();
            bool isnumeric = double.TryParse(prymaidlength, out double n);
            if (isnumeric)
            {
                //print prymaid numbers
                for (int i = 1; i <= double.Parse(prymaidlength); i++)
                {
                    //number of spaces before printing number - (total size / 2) - 1
                    for (int j = 1; j <= (double.Parse(prymaidlength)-i); j++)
                    {
                        Console.Write(" ");
                    }
                    for (int k = 1; k <= i; k++)
                    {
                        Console.Write(k.ToString());
                    }
                    for (int k = i-1; k >= 1; k--)
                    {
                        Console.Write(k.ToString());
                    }
                    Console.WriteLine();
                }
            }
            Console.ReadLine();
Posted by: Guest on July-21-2021

C# Answers by Framework

Browse Popular Code Answers by Language