Found 517 Articles for Swift

Swift Program to find the tangent of given radian value

Ankita Saini
Updated on 26-Aug-2022 11:36:09

128 Views

This tutorial will discuss how to write a Swift program to find the tangent of given radian value. A tangent function is used to define the ratio of the length of the opposite side to the adjacent side in the right-angled triangle. It is also known as the tan function. The mathematical representation of the tangent() function is − tan() = opposite side/adjacent Side In Swift, we can calculate the tangent of the given radian value using the pre-defined tan() function. This function returns the tangent value of the specified number. Here, the specified number represent an angle. Syntax ... Read More

Swift Program to find the cosine of given radian value

Ankita Saini
Updated on 25-Aug-2022 09:02:20

326 Views

This tutorial will discuss how to write a Swift program to find the cosine of given radian value. A cosine function is used to define the ratio of the length of the adjacent side to the hypotenuse in the right-angled triangle. It is also known as the cos function. The mathematical representation of the cosine() function is − cos() = adjacent Side/ hypotenuse In Swift, we can calculate the cosine of the given radian value using the pre-defined cos() function. This function return the cosine value of the specified number between -1 to 1. Here, the specified number represent ... Read More

Swift Program to find the sine of given radian value

Ankita Saini
Updated on 25-Aug-2022 09:01:04

587 Views

This tutorial will discuss how to write a Swift program to find the sine of given radian value. A sine function is used to define the ratio of the length of the opposite side to the hypotenuse in the right-angled triangle. It is also known as the sin function. The mathematical representation of the sine() function is: sin() = opposite Side/ hypotenuse In Swift, we can calculate the sine of the given radian value using the pre-defined sin() function. This function return the sine value of the specified number between -1 to 1. Here, the specified number represents an ... Read More

Swift Program to calculate the volume and area of Sphere

Ankita Saini
Updated on 25-Aug-2022 08:59:43

266 Views

This tutorial will discuss how to write a Swift program to calculate the volume and area of the Sphere. A sphere is a three-dimensional round solid shape or object. Or we can say a sphere is a shape that is defined in three axes: x-axis, y-axis, and z-axis. It does not hold any vertices or edges. Volume of the Sphere The amount of space occupied by a sphere in the three-dimensional plane is known as the volume of a sphere. For example, we want to fill a spherical ball with liquid, so using volume we can calculate the required ... Read More

Swift Program to calculate the volume and area of the Cylinder

Ankita Saini
Updated on 25-Aug-2022 08:56:31

288 Views

This tutorial will discuss how to write a Swift program to calculate the volume and area of the cylinder. A cylinder is a three-dimensional shape that has two identical parallel circular bases joined by a curved surface.Volume of the Cylinder The amount of space occupied by the cylinder in the three-dimensional plane is known as the volume of the cylinder. For example, we want to fill a cylindrical bottle with shampoo, so using volume we can calculate the required amount of shampoo. We can calculate the volume of the cylinder using radius and height of the cylinder. Formula Following is ... Read More

Swift Program to calculate the sum of first N odd numbers

Ankita Saini
Updated on 25-Aug-2022 08:51:55

403 Views

This tutorial will discuss how to write a Swift program to find the sum of first N odd numbers.A number that is not divisible by 2 or we can say that when an odd number is divided by 2 then it leaves some remainder such type of number is known as an odd number. For example, when 2 divides by 2 leave remainder 0 whereas 3 divides by 2 leaves remainder 1. So it means 2 is even number and 3 is an odd number. List of odd numbers is: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, ... Read More

Swift Program to calculate the sum of all odd numbers up to N

Ankita Saini
Updated on 25-Aug-2022 08:29:48

510 Views

This tutorial will discuss how to write a Swift program to find the sum of all odd numbers upto N. A number that is not divisible by 2 or we can say that when an odd number is divided by 2 then it leaves some remainder such type of number is known as an odd number. For example, when 2 divides by 2 leave remainder 0 whereas 3 divides by 2 leaves remainder 1. So it means 2 is an even number and 3 is an odd number. List of odd numbers is − 1, 3, 5, 7, 9, 11, ... Read More

Swift Program to calculate the sum of first N even numbers

Ankita Saini
Updated on 25-Aug-2022 08:25:26

231 Views

This tutorial will discuss how to write a Swift program to calculate the sum of first N even numbers. A number that is multiple of 2 or we can say that a number that is completely divisible by 2(that means leaves no remainder) is known as even number. For example, 2, 4, 6, 8, 10, …etc. are even numbers. We can calculate the sum of the first N even number using the following formula. Formula Following is the formula for the sum of first N even numbers − Sum = N(N + 1) Below is a demonstration of the ... Read More

Swift Program to calculate the sum of all even numbers up to N

Ankita Saini
Updated on 25-Aug-2022 08:20:06

1K+ Views

This tutorial will discuss how to write a Swift program to calculate the sum of all even numbers upto N. A number that is a multiple of 2 or we can say that a number that is completely divisible by 2(that means leaves no remainder) is known as even number. For example, 2, 4, 6, 8, 10, …etc. are even numbers. We can calculate the sum of all the even numbers upto N by adding all the even numbers present in the given list. Below is a demonstration of the same − Input Suppose our given input is − Number ... Read More

Swift Program to find the hypotenuse of a right-angled triangle with sides l and b

Ankita Saini
Updated on 25-Aug-2022 08:12:22

279 Views

This tutorial will discuss how to write a Swift program to find the hypotenuse of a right-angled triangle with sides l and b. A triangle in which one angle is equal to 90 degrees and the sum of the other two angles is also 90 degrees then such type of triangle is known as a right-angled triangle. A right-angled triangle has three sides- base, perpendicular, and hypotenuse. We can find the relationship between these three sides using Pythagoras theorem.In a right-angled triangle, the square of the hypotenuse side(also known as the largest side of the triangle) is equal to the ... Read More

Advertisements