Ankita Saini has Published 319 Articles

Swift Program to Interchange Elements of First and Last Rows of a Matrix

Ankita Saini

Ankita Saini

Updated on 29-Dec-2022 17:21:05

184 Views

In this article, we will learn how to write a swift program to interchange the elements of first and last in a matrix across rows. Therefore, to interchange the elements we need to swap the elements of the first row with the elements of the last row of the given ... Read More

Swift Program to Interchange the Diagonals of a Matrix

Ankita Saini

Ankita Saini

Updated on 29-Dec-2022 17:20:23

145 Views

In this article, we will learn how to write a swift program to interchange the diagonals. Therefore, to interchange the diagonals we need to swap the elements of primary diagonal with the elements of secondary diagonal of the given matrix. For example − Original matrix: 2 4 5 6 ... Read More

Swift Program to Print Boundary Elements of a Matrix

Ankita Saini

Ankita Saini

Updated on 29-Dec-2022 17:11:17

201 Views

In this article, we will learn how to write a swift program to print boundary elements of a matrix. Boundary elements of a matrix are those elements that are present on the boundary of the matrix that are elements in the first row, last row, first column, and last column. ... Read More

Swift Program to Interchange Elements of First and Last Columns of Matrix

Ankita Saini

Ankita Saini

Updated on 29-Dec-2022 17:04:11

209 Views

In this article, we will learn how to write a swift program to interchange the elements of first and last in a matrix across columns. Therefore, to interchange the elements we need to swap the elements of the first column with the elements of the last column of the given ... Read More

Swift Program to Display Lower Triangular Matrix

Ankita Saini

Ankita Saini

Updated on 29-Dec-2022 17:01:30

150 Views

In this article, we will learn how to write a swift program to display lower triangular matrix. Lower triangular matrix is a matrix in which all the elements above primary diagonal are zero. As shown in the below image: $$\mathrm{\begin{bmatrix} 1 & 0 & 0 & 0 & 0 & ... Read More

Swift Program to Calculate Average Using Arrays

Ankita Saini

Ankita Saini

Updated on 29-Dec-2022 15:53:37

2K+ Views

In this article, we will learn how to write a swift program to calculate averages using an array. Average is defined as the ratio of the sum of the elements present in the given sequence to the total number of elements available in the given sequence. The general formula of ... Read More

Swift Program to Find the Transpose

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 16:14:36

345 Views

In this article, we will learn how to write a swift program to find the transpose of a matrix. Transpose of a matrix is calculated by interchange the rows of a matrix into columns or columns of a matrix into rows. For example, we have the following matrix: $$\mathrm{X\:=\:\begin{bmatrix} 13, ... Read More

Swift Program to Sort the Elements of an Array in Descending Order

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 11:27:29

544 Views

In this article, we will learn how to write a swift program to sort the elements of an array in descending order. To sort the elements of an array Swift provides an in-built function named sort(by:). This function takes one argument and then sorts the array according to the condition ... Read More

Swift Program to Sort the Elements of an Array in Ascending Order

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 11:26:00

2K+ Views

In this article, we will learn how to write a swift program to sort the elements of an array in ascending order. Here we are going to use the following 2 methods: sort() function without parameter sort(by:) function with parameter To sort the elements of an array Swift ... Read More

Swift Program to Remove All Occurrences of an Element in an Array

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 11:21:29

620 Views

In this article, we will learn how to write a swift program to remove all occurrences of an element in an array. So here we use the following methods − Using an inbuilt function Without using an inbuilt function Method 1: Using the removeAll() Function To remove all the ... Read More

Advertisements