Found 1082 Articles for Go Programming

Golang Program To Remove All Occurrences Of An Element In An Array

Akhil Sharma
Updated on 02-Jan-2023 15:21:46

481 Views

In this tutorial, we will see to write a go language program to remove all occurrences of an element in an array. Removing occurrences from an array means that we wish to remove an entry completely from the array. Remove All Occurances Of An Element In An Array Using External Function The following code illustrates how we can remove all the occurrences of an element in an array by using a user-defined function. Algorithm Step 1 − Import the fmt package. Step 2 − Defining a function named removeOccurrence(). Step 3 − In this function, we are checking ... Read More

Golang Program To Print Upper Star Triangle Pattern

Akhil Sharma
Updated on 02-Jan-2023 15:19:46

323 Views

In this tutorial, we will write a program to print an upper star triangle pattern in go language. In an upper star triangle pattern, there can be only one star printed in the first row and the base must be at the bottom. Printing Upper Star Triangle Pattern In Go Programming Language Algorithm Step 1 − Import the fmt package. Step 2 − Start the main function. Step 3 − In the next step, we need to initialize the integer variables viz i, j, k, and rows. The row variable contains a number of rows to be printed ... Read More

Golang Program To Interchange The Diagonals

Akhil Sharma
Updated on 02-Jan-2023 15:11:10

85 Views

In this article, we will write a go language program to interchange the diagonal elements of a matrix. Exchange the diagonal elements of a matrix using an external function In this program, we will write a go language program to interchange the diagonal elements of a 3 X 3 matrix using a user-defined function. Algorithm Step 1 − Import the fmt package. Step 2 − Create a function to interchange the diagonal elements of the matrix. In this function, we have defined two variables of integer type and assigned values to them. Step 3 − Use for loop ... Read More

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

Akhil Sharma
Updated on 02-Jan-2023 15:08:41

100 Views

In this article, we will write a go language program to interchange elements of first and last row in a matrix. Interchange Elements Of The First And Last Row 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 row 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 row of a matrix. In this function, we have defined two variables of ... Read More

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

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

120 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

377 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

101 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

683 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

908 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

Golang Program to Find the Product of Two Numbers Using Recursion

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

212 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

Advertisements