Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StructureVolumeOfcuboid
{
public class Program
{
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)
{
Cuboid vol= new Cuboid(10,20,30);
Console.WriteLine("\n Volume of Cubid is"+"="+vol.Volume());
Console.ReadKey();
}
}
}
}
Output:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StructureVolumeOfcuboid
{
public class Program
{
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)
{
Cuboid vol= new Cuboid(10,20,30);
Console.WriteLine("\n Volume of Cubid is"+"="+vol.Volume());
Console.ReadKey();
}
}
}
}
Output:
Thanks for the program. How do I determine other parameters like surface area of the cuboid? And how do I allow for the inputs like the length, width and height to be determined by the user of the program. Thanks.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehttp://dotnetadherents.blogspot.in/search?updated-min=2015-01-01T00:00:00-08:00&updated-max=2016-01-01T00:00:00-08:00&max-results=1
ReplyDelete