find the surface area of a sphere in swift

To find the surface area of a sphere in swift, you can use the following formula:

main.swift
surfaceArea = 4 * π * r * r
28 chars
2 lines

where r is the radius of the sphere, and π is the mathematical constant pi (approximately equal to 3.14159).

Here's the code in Swift:

main.swift
let radius = 5.0
let pi = 3.14159
let surfaceArea = 4 * pi * radius * radius
print("The surface area of the sphere is \(surfaceArea)")
135 chars
5 lines

This code sets the radius of the sphere to 5 units, and calculates the surface area using the formula above. The result is then printed to the console.

gistlibby LogSnag