- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Swift Program to Find the Perimeter of a Circle

This tutorial will discuss how to write a Swift program to find the perimeter of the circle.

Perimeter of the circle is also known as the circumference of the circle. It is used to calculate the boundary of the circle. Suppose we want to fence our circular garden so with the help of perimeter we can calculate the total amount of fence required to cover the boundary of the garden. We can calculate the perimeter of the circle with the help of the radius or diameter, here,

**Radius** − It is known as the distance from the center to a point on the edge of the circle and generally represented by r or R. Or we can say that radius is half of diameter that is r = D/2.

**Diameter** − It is known as a line that passes through the centre of the circle and its endpoint is present on the edge of the circle and generally represented by the word d or D. Or we can say that diameter is double of radius that is D = 2r.

## Formula

Following is the perimeter or circumference of the circle −

Perimeter = 2 * Pi * r

Following is the perimeter or circumference of the circle in terms of diameter −

Perimeter = 2 * Pi * D

## Algorithm to Perimeter using Radius of the circle

**Step 1**− Define Radius**Step 2**− Enter the value of Pi**Step 3**− Enter the formula − 2πr**Step 4**− Print the output

## Example

**Perimeter using radius of the circle**

The following program shows how to calculate the perimeter of the circle with the help of the radius.

import Foundation import Glibc var radius = 10.0 let pi = 3.14 var perimeterOfCircle = 2 * pi * radius print("Radius of the circle is:", radius) print("So the perimeter is:", perimeterOfCircle)

## Output

Radius of the circle is: 10.0 So the perimeter is: 62.800000000000004

In the above code, we calculate the perimeter of the circle with the help of radius of the circle using the following code −

var perimeterOfCircle = 2 * pi * radius

Here the radius of the circle is 10.0. So the perimeter of the circle is 62.800000000000004.

## Algorithm to Perimeter using Diameter of the circle

**Step 1**− Define Diameter**Step 2**− Enter the value of Pi**Step 3**− Enter the formula − πd**Step 4**− Print the output

## Example

**Perimeter using diameter of the circle**

The following program shows how to calculate the perimeter of the circle with the help of the diameter.

import Foundation import Glibc var diameter = 5.0 let pi = 3.14 var perimeterOfCircle = pi * diameter print("Diameter of the circle is:", diameter) print("So the perimeter is:", perimeterOfCircle)

## Output

Diameter of the circle is: 5.0 So the perimeter is: 15.700000000000001

In the above code, we calculate the perimeter of the circle with the help of the diameter using the following code −

var perimeterOfCircle = pi * diameter

Here the diameter of the circle is 5.0. So the perimeter of the circle is 15.7.

- Related Articles
- Swift Program to Find the Perimeter of a Rectangle
- Java Program to Find the Perimeter of a Circle
- Haskell Program to Find the Perimeter of a Circle
- Kotlin Program to Find the Perimeter of a Circle
- Swift Program to Find the Area of a Circle
- How to Find the Perimeter of a Circle in Golang?
- Swift Program to Calculate Area and Perimeter of Equilateral Triangle
- Java Program to find the perimeter of a cylinder
- Java Program to Find the Perimeter of a Rectangle
- Kotlin Program to Find the Perimeter of a Rectangle
- Golang Program to Create a Class and Compute the Area and Perimeter of a Circle
- Swift Program to Calculate Area of Circle Inscribed in Square
- Swift Program To Find The Area of a Trapezium
- Swift Program to Find the Area of a Parallelogram
- Python Program to Create a Class and Compute the Area and the Perimeter of the Circle