Blog

Write Pyramid in c#

Posted by Kailash Chandra Behera Blogs | Articles C# Mar 30, 2013
This code describes how to write pyramid using c#
class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the lenth of pyramid");
            int l = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= l; i++)
            {
                for (int j = 1; j <= l - i; j++)
                {
                    Console.Write(" ");
                }
                for (int j = 1; j <= 2 * i - 1; j++)
                {
                    Console.Write("*");
                }
                Console.WriteLine(" ");
            }
            Console.Read();
        }
    }
PREMIUM SPONSORS
Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.