How to calculate the surface area of cuboid in Swift

1 Answer

0 votes
import Foundation

// Function to calculate the surface area of a cuboid
func surfaceAreaCuboid(length: Double, width: Double, height: Double) -> Double {
    return 2 * (length * width + width * height + height * length)
}

let length = 6.0
let width  = 3.0
let height = 4.0

let surfaceArea = surfaceAreaCuboid(length: length, width: width, height: height)

print("Surface Area of Cuboid is = \(surfaceArea)")



/*
run:

Surface Area of Cuboid is = 108.0

*/

 



answered Mar 3 by avibootz
...