Tuesday, 5 January 2016

christmas tree program in c#

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
         
            for (int x=1; x < 25;x++ )
            {
                int y = 0;
                int z = 25;
                while (z > x)
                {
                    Console.Write(" ");
                    z--;
                };
                while (y < x * 2)
                {                  
                    Console.Write("*");
                    y++;            
                };
                    Console.Write("\n");
            };
            for (int x = 1; x < 7; x++)
            {
                int y = 0;
                while (y < 24)
                {
                    Console.Write(" ");
                    y++;
                };

                Console.WriteLine("****");
            };
                    Console.Read();
        }
    }
}

No comments:

Post a Comment