Found 26504 Articles for Server Side Programming

Swift Program to Find the Trace and Normal of a given Matrix

Ankita Saini
Updated on 29-Dec-2022 17:21:58

152 Views

In this article, we will learn how to write a swift program to find trace and normal of a given matrix. Calculating the Trace of a given Matrix Trace is known as the sum of primary diagonal elements of the given square matrix. For example, we have a 3x3 square matrix − 2 3 4 3 4 6 1 3 2 So the primary diagonal elements are 2, 4 and 2. Hence the trace of the given 3x3 matrix is 2+4+2 = 8. Algorithm Step 1 − Define the size of the matrix. Step 2 − Create a ... Read More

Swift Program to Find the Sum of the Boundary Elements of a Matrix

Ankita Saini
Updated on 29-Dec-2022 17:22:34

174 Views

In this article, we will learn how to write a swift program to find the sum of the 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. For example − Given Matrix: 2 4 5 6 7 8 4 5 6 7 3 2 3 4 5 6 2 1 1 1 1 1 1 1 3 4 3 4 3 4 2 2 2 2 2 2 Boundary elements are: ... Read More

Swift Program to Display Upper Triangular Matrix

Ankita Saini
Updated on 29-Dec-2022 17:23:06

202 Views

In this article, we will learn how to write a swift program to display upper triangular matrix. Upper triangular matrix is a matrix in which all the elements below the primary diagonal are zero. As shown in the below image − $$\mathrm{\begin{bmatrix} 1 & 4 & 6 & 7 & 8 & 8ewline 0 & 5 & 6 & 8 & 9 & 9ewline 0 & 0 & 6 & 7 & 8 & 3ewline 0 & 0 & 0 & 2 & 1 & 1ewline 0 & 0 & 0 & 0 & 2 & 1ewline 0 & 0 ... Read More

Swift Program to Display Lower Triangular Matrix

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

243 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 & 0ewline 3 & 5 & 0 & 0 & 0 & 0ewline 1 & 4 & 6 & 0 & 0 & 0ewline 1 & 2 & 2 & 2 & 0 & 0ewline 4 & 5 & 6 & 1 & 2 & 0ewline 1 & 1 & 1 ... Read More

Swift Program to Compute the Sum of Diagonals of a Matrix

Ankita Saini
Updated on 29-Dec-2022 17:23:41

794 Views

In this article, we will learn how to write a swift program to compute the sum of diagonals of a matrix. Every matrix has two diagonals which are known as primary and secondary diagonals. For example, we have the following 5x5 square matrix − 2 3 4 5 6 4 6 7 8 9 1 1 1 3 4 4 0 4 0 4 0 0 1 1 1 So the primary diagonal is formed by using elements 2, 6, 1, 0, 1 and the secondary diagonal is formed by using elements 6, 8, 1, 0, 0. Hence the ... Read More

Swift Program to Check Whether Two Matrices Are Equal or Not

Ankita Saini
Updated on 29-Dec-2022 17:24:11

180 Views

In this article, we will learn how to write a swift program to check whether two matrices are equal or not. Here, we create two matrices, and using the not equal to the operator (!=), we check whether all the elements of both matrices are equal or not. Algorithm Step 1 − Create a function. Step 2 − Use nested for loop to iterate through each row and column. Step 3 − Check if the element of matrix1 is not equal to matrix2. If the condition is true, then return 0, otherwise, return 1. Step 4 − Create two ... Read More

Swift Program to Calculate Standard Deviation

Ankita Saini
Updated on 29-Dec-2022 17:24:40

721 Views

In this article, we will learn how to write a swift program to calculate standard deviation. Standard deviation is a measure, which will represent how much variation from the mean exists, or we can say that it is used to calculate the extent to which the values are differ from the average. $$\mathrm{\sigma\:=\:\sqrt{{\frac{1}{N}}\sum_{i=1}^N\:(X_i-\mu)^2}}$$ The mathematical formula of standard deviation is- σ = standard deviation N = total number of elements Xi = ith element \mu = Mean of the given elements Therefore, in this article, we calculate the standard deviation of the given array by using the ... Read More

Swift Program to Calculate Average Using Arrays

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

3K+ 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 average is − Average = (p1+p2+p3+..+pn)/n Here we use the following methods to calculate the average using array − Using pre−define functions Without using predefine functions Method 1: Using Pre-Define Functions To find the average of the given array, we use reduce() method to find the sum ... Read More

Golang Program to Find the Product of Two Numbers Using Recursion

Akhil Sharma
Updated on 29-Dec-2022 12:27:42

399 Views

The product of two numbers is the result you get when you multiply them together. So 15 is the product of 3 and 5 and 22 is the product of 2 and 11 and so on. A Recursion is where a function calls itself by direct or indirect means. Every recursive function has a base case or base condition which is the final executable statement in recursion and halts further calls. Example-1: Golang Program Code to Find The Product of Two Numbers Using Recursion by Using The Direct Recursion Method Syntax Syntax for direct recursion func recursion() { ... Read More

Golang Program to Display Factors of a Number

Akhil Sharma
Updated on 29-Dec-2022 12:25:10

926 Views

In this tutorial program, we will learn how to display the factors of a given number in the Go programming language. A factor of a number is defined as the algebraic expression that divides any given number evenly, with its remainder being zero. All composite numbers will have more than two factors, that include 1 and the number itself also. For example: by multiplying 3 and 7, we get 21. We say 3 and 7 are factors of 21. Below is a demonstration of the same − Input Suppose our input is = 15 Output The factors of 15 ... Read More

Advertisements