To find the surface area of a triangular prism, you need to calculate the areas of all its faces and add them up.
Here's the code to find the surface area of a triangular prism in Swift:
main.swift286 chars6 lines
To use this function, simply call it and provide the values for the base, height and length of your triangular prism:
main.swift154 chars3 lines
This will output:
main.swift51 chars2 lines
So, if the base of the triangular prism is 5 units, height is 7 units and length is 10 units, then the surface area of the prism is 185 square units.
gistlibby LogSnag