using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace Chapter7TwoDArray

{

   

    //create a multiplication table for 0 to 5

    class Program

    {

        static void Main(string[] args)

        {

            int z1 = 4;

            int z2 = 4;

           

            int[,] array = new int[z1, z2];

            int x;

            int y;

            int s;

           

            //generate the X and Y rows

            for (x = 1; x < z1; x++)

            {

                array[x, 0] = x - 1;

            }

            for (y = 1; y < z2; y++)

            {

                array[0, y] = y - 1;

            }

           

            //Calculate the table

            for (x = 2; x < z1; x++)

            {

                for (y =1; y < z2; y++)

                {

                    array[x, y] = (array[0, y] * array[x, 0]);

                }

            }

 

 

 

 

            //prints the array

            for (x = 0; x < z1 ; x++)

            {

                for (y = 0; y < z2; y++)

                {

                    s = array[x, y];

                    Console.Write(s.ToString("000")+"  ");

                }

                Console.WriteLine();

            }

 

            Console.ReadKey();

 

 

           

 

        }

       

    }

 

}

 

 

Output of code

000  000  001  002

000  000  000  000

001  000  001  002

002  000  002  004