# find the surface area of a cone in swift

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

```main.swift```A = πr² + πr√(r² + h²)
```23 chars2 lines```

where `A` is the surface area of the cone, `r` is the radius of the circular base of the cone, and `h` is the height of the cone.

Here's how you can implement this formula in Swift:

```main.swift```func surfaceAreaOfCone(radius r: Double, height h: Double) -> Double {
let π = Double.pi
let baseArea = π * r * r
let slantHeight = sqrt(pow(r, 2) + pow(h, 2))
let lateralArea = π * r * slantHeight
let surfaceArea = baseArea + lateralArea
return surfaceArea
}
```284 chars9 lines```

You can then call this function with the radius and height of the cone as arguments:

```main.swift```let radius = 3.0
let height = 4.0
```main.swift```The surface area of a cone with radius 3.0 and height 4.0 is 75.39822368615503.
Note that the `sqrt` function is used to calculate the slant height `l` of the cone by applying the Pythagorean theorem (`l² = r² + h²`).