21 October 2013

Numbers pyramid in c#.net

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int number_of_layer = 7, Space, Number;
            Console.WriteLine("Print paramid");
            for (int i = 1; i <= number_of_layer; i++) // Total number of layer for pramid
            {
                for (Space = 1; Space <= (number_of_layer - i); Space++)  // Loop For Space
                    Console.Write(" ");
                for (Number = 1; Number <= i; Number++) //increase the value
                    Console.Write(Number);
                for (Number = (i - 1); Number >= 1; Number--)  //decrease the value
                    Console.Write(Number);
                Console.WriteLine();
              
            }
            Console.ReadLine();
        }
    }
}




No comments:

Post a Comment