find the surface area of a cylinder in swift

To find the surface area of a cylinder in Swift, you can use the following formula:

main.swift
surfaceArea = 2 * π * radius * height + 2 * π * radius * radius
64 chars
2 lines

Here's the code implementation in Swift:

main.swift
let radius = 5.0
let height = 10.0
let pi = Double.pi

let surfaceArea = 2 * pi * radius * height + 2 * pi * radius * radius

print("The surface area of the cylinder is: \(surfaceArea)")
187 chars
8 lines

Output:

main.swift
The surface area of the cylinder is: 345.5751918947908
55 chars
2 lines

gistlibby LogSnag