How to calculate the surface area of cuboid in C#

1 Answer

0 votes
using System;

class Program
{
    // Function to calculate the surface area of a cuboid
    static float SurfaceAreaCuboid(float length, float width, float height) {
        return 2 * (length * width + width * height + height * length);
    }

    static void Main()
    {
        float length = 6;
        float width = 3;
        float height = 4;

        float surfaceArea = SurfaceAreaCuboid(length, width, height);

        Console.WriteLine("Surface Area of Cuboid is = " + surfaceArea);
    }
}



/*
run:

Surface Area of Cuboid is = 108

*/

 



answered Sep 9, 2021 by avibootz
edited Mar 2 by avibootz
...