Found 33676 Articles for Programming

Golang Program To Interchange Elements Of First And Last In A Matrix Across Columns

Akhil Sharma
Updated on 02-Jan-2023 15:06:49

200 Views

In this article, we will write a go language program to interchange elements of the first and last column in a matrix. Interchange Elements Of The First And Last Column In A Matrix Using An External Function In this program, we will write a go language program to interchange the elements of the first and last column of a 3 X 3 matrix using an external function. Algorithm Step 1 − Import the fmt package. Step 2 − Create a function to interchange the first and last columns of a matrix. In this function, we have defined two variables ... Read More

Golang Program To Find The Transpose

Akhil Sharma
Updated on 02-Jan-2023 15:05:28

559 Views

In this article, we will write a go language program to find the transpose of a matrix. A matrix is a collection of numbers that are arranged in rows and columns, which is a two-dimensional array. Find The Transpose Of A Matrix The following code illustrates an example to find the transpose of a matrix. Algorithm Step 1 − Import the fmt package. Step 2 − Call the main() function. Step 3 − Initialize a 2-d array called matrixA and matrix and store elements in it. Step 4 − Print the matrices on the screen. Step ... Read More

Golang Program To Find The Trace And Normal Of A Matrix

Akhil Sharma
Updated on 02-Jan-2023 15:04:02

159 Views

In this tutorial, we will write an article to find the normal and trace of a matrix. A matrix is considered normal if its square root equals the sum of the squares of each member and the trace is the total of a matrix's diagonal elements. Golang Program To Find The Normal Finding Normal of 2x2 Matrix In this example, we will see how we can find the normal of a 2 X 2 matrix. Algorithm Step 1 − First, we need to import the fmt and math package. Step 2 − Create a function to find the Normal ... Read More

Golang Program To Find Common Array Elements

Akhil Sharma
Updated on 02-Jan-2023 14:58:02

915 Views

In this tutorial, we will see to write a go language program to find common elements in two arrays. Find Common Array Elements Using User-Defined Function The following code illustrates how we can find the common elements in two different arrays of strings. Algorithm Step 1 − import the fmt package. Step 2 − Define a function named intersection() that accepts the two arrays as arguments and returns the resultant array as an output to the function. Step 3 − Create an empty array of strings called out and a map called bucket. Step 4 − Use for ... Read More

Golang Program To Copy All The Elements Of One Array To Another Array

Akhil Sharma
Updated on 02-Jan-2023 14:55:40

1K+ Views

In this tutorial, we will see to write a go language program to copy all the elements of one array to another array. Copy All The Elements Of One Array To Another Array Using Equality Operator Let us now look at a go language code to copy all the elements of one array to another array by using equality operator. Algorithm Step 1 − Impot the fmt package that. Step 2 − Call the main() function. Step 3 − Initialize and define an array of type strings and store values to it. Step 4 − Print this ... Read More

What does "Fatal error: Unexpectedly found nil while unwrapping an Optional value" mean?

Nitin Aggarwal
Updated on 02-Jan-2023 14:29:11

5K+ Views

This error is very frequent as you can see many times while writing code. Don't worry, you will understand this error in detail in this article. Before jumping to the cause of this error, let's understand what is optional in Swift. Optional Initially, when we receive a value from another source, such as the backend server, it might contain a valid value or nothing at all. In that case, you use optionals that represent a variable with two possible situations: either a value or no value at all. var possibleNumber = "450" var convertedNumber = Int(possibleNumber) In the above ... Read More

Swift: print() vs println() vs NSLog()

Nitin Aggarwal
Updated on 02-Jan-2023 14:30:46

2K+ Views

In this article, you will learn about logging methods in the Swift language. You will also learn what the differences between them are. Debugging is the most common practice while writing code for an iOS application. It enables you to debug logic, code, errors, etc. Swift provides in-built libraries to print logs on the console. We have some options to print logs on the console like print(), println(), and NSLog(). Let's try to understand each of them. print() In Swift, print() is a function that prints a message to standard output (e.g., the console). It takes one or more arguments, ... Read More

Loading/Downloading an image from a URL in Swift

Nitin Aggarwal
Updated on 02-Jan-2023 14:25:57

8K+ Views

In this article, you will learn how you can download an image from a URL in the Swift language. In the iOS application, image downloading from the image URL is the most common task. Apple provides us with a native library to download any data from any URL. There are many third-party libraries available on GitHub to download the images. But in this tutorial, we are not going to use any third-party library. We will use the URLSession class provided by Apple itself. What is the URLSession Class? URLSession is a class in the Foundation framework that provides an API ... Read More

How to find the index of a list item in Swift?

Nitin Aggarwal
Updated on 02-Jan-2023 13:40:14

16K+ Views

Swift gives you some methods to perform on the collection type to get the index of a particular object. To find the index of an item in an array in Swift, you can use the firstIndex(of:) method of the Array type. This method returns the index of the first element in the array that is equal to the given element or nil if no such element is found. How to print the Index of List items? Let's look at an example. Algorithm Step 1 − Define an input array. Step 2 − Call the firstIndex() method on the input array. ... Read More

How to add constraints programmatically using Swift

Nitin Aggarwal
Updated on 02-Jan-2023 12:57:00

13K+ Views

The goal of this article is to explain how you can add constraints programmatically in the Swift language. To programmatically add constraints in Swift, you can use the NSLayoutConstraint class to define the constraints you want to add. Concepts That Will Be Used To Add Constraints Are The Following The translatesAutoresizingMaskIntoConstraints is a property of UIView in the UIKit framework. It is a boolean value that determines whether the view's autoresizingMask properties are translated into Auto Layout constraints. When translatesAutoresizingMaskIntoConstraints is set to NO, the autoresizingMask is ignored and the view is resized accrding to any constraints that have been ... Read More

Advertisements