Tuesday, August 10, 2010

Program on Three Dimensional Arrays.


Write a program on Three Dimensional Arrays.
public void ThreeDimensionalarray()
        {
            int m, n,o;
            Console.WriteLine("\n Enter the length of two dimensional array");
            m = Convert.ToInt32(Console.ReadLine());
            n = Convert.ToInt32(Console.ReadLine());
            o = Convert.ToInt32(Console.ReadLine());
            int[,,] array = new int[m, n,o];
          
            Console.WriteLine("Enter the elements of array");
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < o; k++)
                    {
                        array[i, j,o] = Convert.ToInt32(Console.ReadLine());
                    }
                }
            }
            Console.WriteLine("The Elements of array are:");
            for (int i = 0; i < m; i++)
            {
                Console.Write("\n");
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < o; k++)
                    {
                        Console.Write("{0}\t", array[i, j,o]);
                    }
                }
            }
        }

No comments:

Post a Comment