Found 517 Articles for Swift

Swift Program to calculate the area of the rhombus

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

180 Views

This tutorial will discuss how to write a Swift program to calculate the area of the rhombus. A rhombus is a closed two-dimensional figure or we can say that a rhombus is a quadrilateral whose all the sides are equal and the diagonals intersect each other at a right angle(that is 90 degrees). The area of the rhombus is known as the total space enclosed inside the boundaries of the rhombus. We can calculate the area of the rhombus using any of the following methods − Area of rhombus using diagonal Area of rhombus using base and height ... Read More

Swift Program to calculate the volume of Cube

Ankita Saini
Updated on 25-Aug-2022 07:51:24

337 Views

This tutorial will discuss how to write a Swift program to find the volume of cube. A cube is a solid three-dimensional shape with six square faces and all the sides of the cube are of equal length(that means Length = Breadth = Width). It is also known as a regular hexahedron. It contains 12 edges and 8 vertices.The total number of cubic units contained by the cube is known as the volume of the cube. To calculate the volume of the cube we find the product of length, height, and width. As we know that length = height = ... Read More

Swift Program to calculate the area of Cube

Ankita Saini
Updated on 25-Aug-2022 07:32:58

231 Views

This tutorial will discuss how to write a Swift program to find the area of the cube. A cube is solid three dimensional shape with six square faces and all the sides of the cube are of equal length(that means Length = Breadth = Width). It is also known as regular hexahedron.The area of a cube is known as the total space enclosed inside the boundaries of the cube. The area of cube is of two types- Total surface area Lateral surface area Total Surface Area The total area occupied by all the six faces of the cube ... Read More

Swift Program to find the area of the rectangle

Ankita Saini
Updated on 26-Aug-2022 11:17:53

564 Views

This tutorial will discuss how to write a Swift program to find the area of the rectangle. A rectangle is a quadrilateral or a closed two-dimensional shape with four sides. All the angles of a rectangle are equal (90 degrees) and the opposite sides are equal and parallel with each other.The area of the rectangle is known as the total space enclosed inside the boundaries of the rectangle. We can calculate the area of the rectangle by multiplying the length and width. Formula for Area of Rectangle Following is the formula for the area of the rectangle − Area = ... Read More

Swift Program to Find Sum of Even Fibonacci Terms Till number N

Ankita Saini
Updated on 19-Aug-2022 10:02:42

890 Views

This tutorial will discuss how to write a Swift program to find sum of even fibonacci terms till number N. A series of numbers in which every number is the sum of the two preceding numbers is known as Fibonacci series. The starting number of the Fibonacci series is 0 and 1, so the series is − 0, 1, 1, 2, 3, 5, 8, 13, 21, …… A number that is multiple of two is known as the even number. Or in other words, a number that is completely divisible by two is known as even number. For example, 2, ... Read More

Swift Program to Find LCM of two Numbers

Ankita Saini
Updated on 18-Aug-2022 13:24:57

641 Views

This tutorial will discuss how to write a Swift program to find LCM of two numbers. LCM is also known as Least Common Multiple. It is used to calculate the smallest common multiple between two or more numbers. Here common multiple represents a number which is multiple of two or numbers. For example, we have two numbers 10 and 8 Factor of 10 = 2 x 5 Factor of 8 = 2 x 2 x 2 Union of both factors = 2 x 2 x 2 x 5 = 40 So the LCM of 10 and 8 is 40. This ... Read More

Swift Program to Find GCD of two Numbers

Ankita Saini
Updated on 18-Aug-2022 13:20:37

874 Views

This tutorial will discuss how to write a Swift program to find GCD of two numbers. GCD is also known as Greatest Common Divisor or HCF(Highest common factor). GCD of two positive number is defined as the greater positive number which is the common factor of both the given two positive numbers. The value of GCD cannot be 0 or negative. The minimum value of GCD of two numbers is always 1. For example, we have two numbers 24 and 30. Factor of 24 = 2 x 2 x 2 x 3 Factor of 30 = 2 x 3 x ... Read More

Swift Program to Round a Number to n Decimal Places

Ankita Saini
Updated on 18-Aug-2022 13:14:28

6K+ Views

This tutorial will discuss how to write a Swift program to round a number to n decimal places. Rounding a number means round a decimal number to a certain number of decimal places or we can say round to the nearest wholes, tenths, hundredths, or thousandth. It save time and helps to express long term into short term. Rounding is only applicable on Float and Double data types. When you round a number always remember the following points − If the last digit is less than 5(that is 0, 1, 2, 3, 4) then round the previous digit down. For ... Read More

Swift Program to Sort Elements in Lexicographical Order (Dictionary Order)

Ankita Saini
Updated on 18-Aug-2022 13:07:44

401 Views

This tutorial will discuss how to write a Swift program to sort elements in lexicographical order(Dictionary order). An arrangement of the words, characters or numbers in alphabetical order staring from A to Z is known as lexicographic order. It is also known as dictionary order because the searching of the words are same as we search in the real dictionary. In lexicographical order, the words whose first letter is same are arranged in the same group and in the group words are sorted according to their second letter and so on. To sort the given list of elements into lexicographic ... Read More

Swift Program to Count the Number of Vowels and Consonants in a Sentence

Ankita Saini
Updated on 18-Aug-2022 13:01:24

1K+ Views

This tutorial will discuss how to write a Swift program to count the number of vowels and consonants in a sentence. An alphabet contains 26 letters out of which 5 are vowels and 21 are consonants. A, E, I, O, and U are known as vowels and B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z are known as consonants. Below is a demonstration of the same − Input Suppose our given input is − Entered String I like momos Output The desired output would be − ... Read More

Advertisements