Calculate Area of Enneagon in Swift

Ankita Saini
Updated on 30-Nov-2022 07:16:34

210 Views

This tutorial will discuss how to write swift program to calculate area of enneagon. A enneagon is a polygon with 9 straight sides and 9 vertices. The sum of all the interior angles is 1260 degree. The total amount of space enclosed inside the nine sides of the enneagon is known as the area of the enneagon. Formula Following is the formula of the area of the enneagon − Area = ((x2*9) / 4*tan (20°)) ∼= (6.18 * x2) Here, x is the side of the enneagon. Below is a demonstration of the same − Input Suppose our ... Read More

Calculate Area and Perimeter of Equilateral Triangle in Swift

Ankita Saini
Updated on 30-Nov-2022 07:14:57

591 Views

This tutorial will discuss how to write swift program to calculate area and perimeter of equilateral triangle A triangle whose all sides and angles are equal is known as the equilateral triangle. Each angle of equilateral triangle is 60 degrees. It is also known as 3-side polygon. Area of Equilateral Triangle The amount of space occupied between the three lines of the triangle is known as the area of the equilateral triangle. Formula Following is the formula − Area = √3x2/ 4 Here x is the side of the equilateral triangle. Below is a demonstration of the ... Read More

Find the Mid Point of a Line in Swift

Ankita Saini
Updated on 30-Nov-2022 07:11:17

436 Views

This tutorial will discuss how to write swift program to find the mid-point of a line. A point lies between the middle of two points is known as mid-point. Suppose we have two points A and B and C point is the mid-point located between A and B. Midpoint always divide lines segment in equal parts. Or we can say mid-point is always equidistant from other two points. Formula Following is the formula − Midpoint = ((a1+a2)/2, (b1+b2)/2) Below is a demonstration of the same − Input Suppose our given input is − Point 1: (5.0, 6.0) ... Read More

Calculate Distance Between Two Points in Swift

Ankita Saini
Updated on 30-Nov-2022 07:09:45

781 Views

This tutorial will discuss how to write swift program to calculate distance between two points. Suppose we have two points and a line connect these points together. So the length of the line is known as the distance between two points in a plane. This formula is used to find the distance between two points in XYplane. Formula Following is the formula − Distance = sqrt((a2-a1) + (b2-b1)) Below is a demonstration of the same − Input Suppose our given input is − Point 1: (1.0, 2.0) Point 2: (3.0, 4.0) Output The desired output would ... Read More

Calculate Area of Pentagon in Swift

Ankita Saini
Updated on 30-Nov-2022 07:08:13

258 Views

This tutorial will discuss how to write swift program to calculate area of pentagon. A pentagon is a two-dimensional shape with 5 sides. It also contains five interior angles and their sum is 540 degrees. It is also known as five side polygon. The total amount of space enclosed inside the five sides of the pentagon is known as the area of the pentagon. Formula Following is the formula of the area of the pentagon: Area = 1/4(sqrt(5(5+2√5))q2) Below is a demonstration of the same − Input Suppose our given input is − side = 6 ... Read More

Calculate Area of Hexagon in Swift

Ankita Saini
Updated on 30-Nov-2022 07:06:40

280 Views

This tutorial will discuss how to write swift program to calculate area of hexagon. A hexagon is a two-dimensional shape with 6 sides of same or different length. It contains six vertices and six interior angles. Hexagon is classified into four types according to their length and internal angles − Regular Hexagon Irregular Hexagon Convex Hexagon Concave Hexagon In this article we will find the area of Regular hexagon. Regular hexagon are those hexagons in which the all the sides are of equal length. The sum of all six interior angles is 720 degrees and the sum of ... Read More

Calculate Area of Octagon in Swift

Ankita Saini
Updated on 30-Nov-2022 07:05:19

195 Views

This tutorial will discuss how to write swift program to calculate area of octagon. An octagon is a two-dimensional shape with 8 sides and also consists of eight interior and exterior angles. The total amount of space enclosed inside the octagon is known as the area of the octagon. Formula: Following is the formula of the area of the octagon − Area = 2 *(side)2*(1+√2) Below is a demonstration of the same − Input Suppose our given input is − side = 15 Output The desired output would be − Area of octagon = 1086.3961030678927 ... Read More

Calculate Area of Circle Inscribed in Square using Swift

Ankita Saini
Updated on 30-Nov-2022 07:02:33

407 Views

This tutorial will discuss how to write swift program to calculate area of circle inscribed in square. We have a figure in which a circle is inscribed in a square. Which means the centre of the circle and the square is same and the diameter of the circle is equal to the length of the side of the square. If we have at least one measurement of square or the circle, then we can easily calculate the area and perimeter of the square, or area and circumference and area of the circle. Here we find the area of the ... Read More

Print Diagonal Matrix Pattern in Swift

Ankita Saini
Updated on 30-Nov-2022 06:35:43

421 Views

This tutorial will discuss how to write swift program to print Diagonal Matrix pattern. Diagonal matrix are those matrix in which all the elements are 0 except the principal diagonal.Or we can say that in a diagonal matrix off diagonal blocks are 0 and main diagonal blocks are square matrices. To create a diagonal matrix pattern we can use any of the following method − Using nested for loop Using stride Function Below is a demonstration of the same − Input Suppose our given input is − Num = 3 Output The desired output would be − 1 0 ... Read More

Print Half Diamond Binary Pattern in Swift

Ankita Saini
Updated on 30-Nov-2022 06:34:58

220 Views

This tutorial will discuss how to write swift program to print half diamond binary pattern. Binary pattern is a sequence of “0” and “1” which is used to develop different patterns or shapes like pyramid, rectangle, cross, etc. To create a half diamond binary pattern, we can use any of the following methods − Using nested for loop Using init() Function Using stride Function Below is a demonstration of the same − Input Suppose our given input is − Num = 3 Output The desired output would be − 0 0 1 0 1 0 ... Read More

Advertisements