- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 517 Articles for Swift
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
496 Views
A number is a perfect cube if the result of the three time multiplication of a whole number is the number itself. For example: number 5 is a per Number = 125 125 = 5*5*5 Here 125 is a perfect cube. Number = 98 Here 98 is not a perfect cube. In this article, we will learn how to write a swift program to check whether a number is a perfect cube or not. Method 1: Using user defined function To check if the given number is a perfect cube or not, we create a function that check each number ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
372 Views
A perfect number is a positive number that is equal to the sum of its factors, excluding the number itself. For example − Number = 6 Proper divisors = 1, 2, 3 Hence, 6 is the perfect number because the sum of its divisors is 6(1+2+3) Number = 10 Proper divisors = 1, 2, 5 Hence, 10 is not a perfect number because the sum of its divisors is 8(1+2+5) In this article, we will learn how to write a swift program to check if the given number is a perfect number or not. Algorithm Step 1 − Create ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
218 Views
A matrix is an arrangement of numbers in rows and columns. Matrix can be of various type like square matrix, horizontal matrix, vertical matrix etc.In this article, we will learn how to write a swift program to calculate the sum of rows of matrix elements. Here we are using the following methods to find the sum of the rows elements − Using nested for-in loop Using in-built function Method 1: Using nested for-in loop Here we use nested for-in loop to find the sum of rows of matrix elements. Algorithm Step 1 − Create a function. Step 2 ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
192 Views
A matrix is a rectangular array of numbers. Or we can say that a matrix is an arrangement of numbers in rows and columns. Matrix can be of various type like square matrix, horizontal matrix, vertical matrix etc. In this article, we will learn how to write a swift program to calculate the sum of matrix elements. So here, using the following methods we calculate the sum of matrix elements. Sum of square matrix elements Sum of any matrix elements For example, we have the following matrix − $\mathrm{Matrix\:=\:\begin{bmatrix}1 & 4 & 5 & 6ewline4 & 7 ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
425 Views
A matrix is an arrangement of numbers in rows and columns. The matrix can be of various types like square, horizontal, vertical, etc. In this article, we will learn how to write a swift program to calculate the sum of columns of matrix elements. Here we are using the following methods to find the sum of the column’s elements − Using a nested for-in loop Using in-built function Method 1: Using nested for-in loop Here we use a nested for-in loop to find the sum of columns of matrix elements. Algorithm Step 1 − Create a function. Step ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
189 Views
Method overloading is a technique that allows us to create multiple methods of same name within a single class but with different parameter types or different number of parameters. The specific method that is called is determined by the types or number of arguments passed to it at the time of the method call. For example − class Book { // Methods func Author(){} func Author(x: Int)->Int{} func Author(x: String)->String{} func Author(a: Int, b: String)->Int{} } Here, the class Book has four overloaded methods. ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
3K+ Views
An array is used to store elements of same data type in an order. In this article, we will learn how to write a swift program to iterate over an array. Here we use the following methods to iterate through each element of the array − Using for-in loop Using forEach() function Using while loop Using enumerated() function Method 1: Using for-in loop To iterate over an array we can use for-in loop. Syntax for value in Sequence { // statement } Here, the value parameter contains an element of the array during the ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
877 Views
An array is used to store elements of same data type. In this article, we will learn how to write a swift program to insert multiple elements into the array from the specified index. Here we use the following methods to insert multiple elements into the array from the specified index − Using Index Using insert(contentsOf:at:) function Method 1: Using Index Here we use square brackets[] along with rang operators to insert multiple elements into the array at the specified index. Algorithm Step 1 − Create an array of integer. Step 2 − Create another array ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
307 Views
An array is used to store elements of same data type in an order. So now we extract the array elements after N elements. For example − Array : [2, 4, 5, 6, 7, 9] N = 3 ResultArray = [6, 7, 9] In this article, we will learn how to write a swift program to get array elements after N elements. Algorithm Step 1 − Create function. Step 2 − Create a new array using Array() initializer that containing elements after N elements. Step 3 − Return the resultant array. Step 4 − Create an array and a ... Read More
![Ankita Saini](https://www.tutorialspoint.com/assets/profiles/489852/profile/60_2374666-1658225115.jpg)
674 Views
An array is used to store elements of the same data type in order. Here we will learn how to write a swift program to find the index of the first occurrence of the specified item in the array. To achieve that we are going to use the following methods to find the index of the first occurrence of the array element − Using user-defined function Using firstIndex() function Method 1: Using user-defined function To find the index of the first occurrence of the specified element in the array we create a function which iterate through each elements ... Read More