Search This Blog

Saturday, 12 September 2015

Pyramid program in C# (Type 2)

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 5; i++)
            {
                Console.WriteLine(" ");
                for (int j = 5; j > i; j--)
                {
                    Console.Write(" ");
                }
                for (int l = 1; l <= i; l++)
                {
                    Console.Write("*");
                }
            }
            Console.ReadKey();
        }
    }

}

Output:

     *
    **
   ***
  ****
 *****

No comments:

Post a Comment