Friday, 13 February 2015

C# Structure Volume Of Cuboid Program(User input)

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

namespace areaofrectangle
{
       struct Cuboid
        {
            int length;
            int breadth;
            int height;

            Cuboid(int x, int y,int z)
            {
                length = x;
                breadth = y;
                height = z;
            }
          int Volume()
            {
               return length * breadth*height;
            }

            public static void Main(string[] args)
            {
                Console.WriteLine("Enter the value of x");
                int x = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the value of y");
                int y = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the value of z");
                int z = Convert.ToInt32(Console.ReadLine());
                Cuboid vol= new Cuboid(x,y,z);
                Console.WriteLine("Volume of Cubid is"+"="+vol.Volume());



             
                Console.ReadKey();
            }
        }
}

Output: