Programming Articles - Page 502 of 3363

Golang Program To Remove The First Given Number Of Items From The Array

Akhil Sharma
Updated on 10-Jan-2023 14:53:02

1K+ Views

In this tutorial, we will write a go language program to remove the first given number of items from an array. We can do this by either using the inbuilt functions in go or using the for loops. The first method is more efficient in functionality than the second one but we will discuss both these methods in this program. Method 1: Remove the First given Number of Items from an Array of Integers using Internal Functions In this method, we will write a go language program to remove the first given number of items from an array by using ... Read More

Golang Program To Determine If a Given Matrix is a Sparse Matrix

Akhil Sharma
Updated on 10-Jan-2023 14:50:29

244 Views

In this tutorial, we will write a go language program to determine whether a given matrix is sparce or not. A square matrix is called a sparse matrix if the number of zeroes present in the matrix are more than the non-zero elements in the matrix. Golang Program to Check if a Matrix is Sparce In this example, we will write a Golang program to check the sparce matrix. We will use for loops along with if conditions to achieve the result in the main section of the program. Algorithm Step 1 − First, we need to import the fmt ... Read More

Golang Program To Get The Last Item From The Array

Akhil Sharma
Updated on 10-Jan-2023 14:47:59

2K+ Views

In this tutorial, we will write a go language program to get the last item from an array. An array is a data structure that is used to store elements in contiguous memory locations. In this article, we will write two programs to store the first element in the array. In the first program, we will use the concept of indexing and in the second we will use the for loops to get the required result. Method 1: Get the Last Item from the Array of Integers in the Main In this method, we will write a golang program ... Read More

Golang Program to Calculate Difference Between Two Time Periods

Akhil Sharma
Updated on 10-Jan-2023 14:46:04

12K+ Views

In this tutorial, we will write a golang programs to calculate the difference between two time periods given in the following programs. To get the time difference between two time periods we can either use a library function or can create a separate user-defined function to achieve the results. Method 1: Calculate the Difference between Two Time Periods using Internal Function In this method, we will write a go language program to find the difference between time periods using pre-defined functions in go programming language. Syntax func (t Time) Sub(u Time) Duration The sub() function in go is ... Read More

Golang Program To Append An Element Into An Array

Akhil Sharma
Updated on 10-Jan-2023 14:43:24

15K+ Views

In this tutorial, we will write a go language program to iterate over an array. An array is a data structure, which is used to store data at contiguous memory locations. There are many methods to append an element in an array. We shall discuss them in this program Example 1: Add Values to an Array of Strings in the Main() Function In this example, we will write a go language program to add values to an array of strings in the main() function. We will first initialize an array of strings of specific size and then add values ... Read More

Golang Program To Convert An Array Into A String And Join Elements With A Specified Character

Akhil Sharma
Updated on 10-Jan-2023 14:41:13

9K+ Views

In this tutorial, we will write a go language program to convert an array to a string and separate them by a specified character. Arrays are data structures that are used to store values at contiguous memory locations. Method 1: Convert an Array into a String using Join() Function In this method, we will write a golang program to convert an array to a string using a library function. We will make a separate function, which will accept the array to be converted as an argument, and convert it to the string, and returns the result. Syntax func ... Read More

Python for MATLAB Users

Prerna Tiwari
Updated on 09-Jan-2023 16:38:34

725 Views

When we move from our academics into the industry, especially engineering individuals, we face a very common problem that we are mainly taught about the obsolete or near obsolete technologies. For example, many schools still use MATLAB. In the engineering sector, whether it is chemical engineer, electrical engineer, or nanoengineer, everyone must have used MATLAB. But in recent times, we can see businesses are shifting from MATLAB to Python. This can be due to a variety of reasons − $1000 licensing cost Inefficient memory allocation Dearth of open source libraries Detest MATLAB syntax. The people who want ... Read More

Swift Program to Subtract Two Matrix Using Multi-dimensional Arrays

Ankita Saini
Updated on 09-Jan-2023 15:22:58

415 Views

In this article, we will learn how to write a swift program to subtract two matrices using multi-dimensional arrays. A matrix is a mathematical structure in which the elements are placed in rows and columns format. For example, the first element is present at a00 location, the second at a01, and so on. So to subtract two matrices we are going to use the - operator to subtract the elements of two matrices like a00 - b00 and then store the sum into a new matrix. For example − Matrix 1 − $\mathrm{\begin{bmatrix}1 & 8 & 4 ewline8 & 8 ... Read More

Swift Program to Search an Element in an Array

Ankita Saini
Updated on 09-Jan-2023 15:19:47

2K+ Views

In this article, we will learn how to write a swift program to search an element in an Array. Here we use the following methods to search elements from the given array: To search Using == operator Using contains() method Using the in function Method 1: Using == operator To search for an element from the given array we iterate through each element of the given array and check if the element is equal to the specified element using the == operator. If true, then the specified element is present in the array. Otherwise not. Algorithm ... Read More

Swift Program to Remove Duplicate Elements From an Array

Ankita Saini
Updated on 09-Jan-2023 15:17:44

9K+ Views

In this article, we will learn how to write a swift program to remove duplicate elements from an array. As we know that an array can store multiple elements of the same type. It is not necessary that all the elements are unique they can be duplicated. For example, arr = [3, 5, 6, 3, 7, 8, 3, 7, 7] here 3 and 7 are duplicate elements. So here we use the following methods to remove duplicate elements − Using contains() method Using Set() initializer Method 1: Using contains() method To remove duplicate elements from the array we ... Read More

Advertisements