Found 33676 Articles for Programming

Swift Program to Reverse a Number

Ankita Saini
Updated on 05-Aug-2022 07:53:46

3K+ Views

This tutorial will discuss how to write a Swift program to reverse a number. Reversing a number is a process in which the position of the digits of a number is interchanged to reverse their order. Below is a demonstration of the same − Suppose we enter the following input − Number = 098627 Following is the desired output − Reversed order = 726890 Algorithm Following is The algorithm to reverse the number − Step 1 − Start Step 2 − Create a variable named “number”. Now the value of the “number” variable is either user-defined or ... Read More

Swift Program To Perform nCr (rcombinations)

Ankita Saini
Updated on 05-Aug-2022 07:50:52

358 Views

This tutorial will discuss how to write a Swift program to perform nCr(r-combination). nCr refers to r- combination. It is used to calculate the possible arrangements where the order of the selection does not matter. Or we can say that nCr is used to select r items from the set of n items where the order of the items does not consider. Formula Following is the formula of nCr nCr = (n!)/(r! * (n - r)!) Below is a demonstration of the same − Suppose we enter the following input. N = 5 R = 3 Following is the ... Read More

Swift Program to Find the Largest Among Three Numbers

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

2K+ 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

5K+ 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

913 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

643 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

270 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

536 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

645 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

246 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

Advertisements