Found 517 Articles for Swift

Swift Program to Find the Largest Among Three Numbers

Ankita Saini
Updated on 05-Aug-2022 07:47:08

1K+ Views

This tutorial will discuss how to write a Swift program to find the largest among three numbers. Given three numbers now we have to find the largest among the given three numbers. So we will compare all three numbers with each other to find the largest number. Below is a demonstration of the same − Suppose we enter the following input − 39, 87, 12 Following is the desired output − Largest number is 87 Finding largest number using max() function Swift provides an in-built method named as max() function. This function returns the maximum number ... Read More

Swift Program to Find Factorial of a number

Ankita Saini
Updated on 05-Aug-2022 07:38:43

3K+ Views

This tutorial will discuss how to write a Swift program to find factorial of a number. A Factorial of a non-negative number is calculated by multiplying the number with every whole number till 1 for example, 6! = 6 x 5 x 4 x 3 x 2 x 1 = 720 which means the factorial of 6 is 720. The general form of factorial is − M! = m x (m - 1) x (m - 2) x (m - 3) …. X 1 Formula Following is the formula of factorial − M! = M * (M - 1)! ... Read More

Swift Program to Find the Surface area and Volume of Cuboid

Ankita Saini
Updated on 01-Aug-2022 14:36:37

547 Views

This tutorial will discuss how to write a swift program to find the surface area and volume of cuboid. A Cuboid is a 3-dimensional solid figure which contains six rectangular faces, eight vertices and twelve edges. It has three dimensions known as length, breadth, and height and if a cuboid has integer edges then the cuboid is the perfect cuboid. The opposite edges of the cuboid are always parallel to each other and the angle formed by all vertices are 90 degrees Surface area of cuboid Surface area of a cuboid is the total space occupied by the cuboid. ... Read More

Swift Program to Find the Area of a Parallelogram

Ankita Saini
Updated on 02-Aug-2022 14:55:14

515 Views

This tutorial will discuss how to write a swift program to find the area of a parallelogram.A Parallelogram is a quadrilateral that is created using parallel lines.Where the opposite sides are parallel and equal and the opposite angles of the parallelograms are equal. It is of three types - rectangle, square, and rhombus.In a parallelogram, an area is known as the space that is enclosed inside the boundaries or sides of the parallelogram in the two-dimensional plane. Suppose we have a tea try now the area of the parallelogram helps us to find how much paint we required to cover ... Read More

Swift Program To Find The Area of a Trapezium

Ankita Saini
Updated on 02-Aug-2022 14:52:10

171 Views

This tutorial will discuss how to write a swift program to find the area of a trapezium.A trapezium is a quadrilateral with at least a pair of opposite parallel sides. The parallel sides are known as the base and the non-parallel sides are known as the legs of the trapezium. The distance between the parallel sides is known as the height of the trapezium.In a trapezium, an area is known as the space that is enclosed inside the boundaries of the trapezium in the two-dimensional plane. Suppose we have a board, now the area of the trapezium helps us to ... Read More

Swift Program to Find the Perimeter of a Rectangle

Ankita Saini
Updated on 02-Aug-2022 14:50:01

350 Views

This tutorial will discuss how to write a swift program to find the perimeter of a Rectangle.A rectangle is a 2-dimensional closed shape with four sides in which opposite sides are parallel and equal to each other. It also has four angle with 90 degrees each.The perimeter of the rectangle is used to calculate the boundary of the rectangle. Or we can say that it is the total distance covered by the rectangle’s outer boundary as show in the above diagram. It is the one of the most important formula of the rectangle. Suppose we want to fence our rectangular ... Read More

Swift Program to Calculate simple interest and compound interest

Ankita Saini
Updated on 02-Aug-2022 14:43:45

464 Views

This tutorial will discuss how to write a swift program to calculate the simple interest and compound interest. Compound Interest The interest applied on the principal and interest together over a certain period of time is known as the compound interest. Or in other words compound interest is known as the interest on interest. It is calculated after calculating amount. Formula Following is the formula of compound interest − Amount(A) = Principal(P)(1 + Rate/100)Time(t)C.I = Amount(A) - Principal(P) Where Principal(P) − Principal amount represents the amount which is initially invested. Rate(R) − Rate represents the interest rate which applied ... Read More

Swift Program to Check whether the input number is a Neon Number

Ankita Saini
Updated on 01-Aug-2022 13:16:46

143 Views

This tutorial will discuss how to write a swift program to check whether the input number is a Neon Number. In a number system, a number whose sum of digits of square of the number is equal to the number is known as neon number. Below is an example of the neon numbers − Let’s see if number 9 is a neon number or not? - The square of 9 is 81 and the sum of 81 is 9 So 9 is a neon number Let’s take another example - 15 The entered number is not a neon number Here, ... Read More

Swift Program to Calculate Compound Interest

Ankita Saini
Updated on 01-Aug-2022 13:06:01

596 Views

This tutorial will discuss how to write a swift program to calculate compound interest. The interest applied to the principal and interest together over a certain period of time is known as compound interest. In other words, the compound interest is known as the interest on interest. It is calculated after calculating the amount. Formula Following is the formula of compound interest − Amount(A) = Principal(P)(1 + Rate/100)Time(t) C.I = Amount(A) - Principal(P) Where Principal(P) − Principal amount represents the amount that is initially invested. Rate(R) − Rate represents the interest rate, that applied to the principal amount for the ... Read More

Swift Program to Calculate the Sum of Natural Numbers

Ankita Saini
Updated on 01-Aug-2022 14:43:13

675 Views

This tutorial will discuss how to write a swift program to calculate the Sum of Natural Numbers. Natural numbers are the set of whole numbers excluding 0. In other words, natural numbers are the numbers which includes all the positive numbers starting from 1 to infinity. It does not contain negative numbers and 0 in it. For example 2, 3, 67, 49, etc. They are also known as counting numbers. We can find the sum of natural numbers by adding given natural numbers using arithmetic addition operator (+). For example, we have 8 so the sum of natural numbers is ... Read More

Advertisements