Golang Array Programs
- Golang program to demonstrate the example of an Array
- Golang program to demonstrate the shorthand declaration of an Array
- Golang program to create an array without specifying its size
- Golang program to get the size of the array
- Golang program to print the array elements without using the loop
- Golang program to create an array with the existing array
- Golang program to compare two arrays using equal to (==) operator
- Golang program to calculate the sum of all array elements
- Golang program to find the largest elements from the array
- Golang program to find the second largest elements from the array
- Golang program to print even numbers of the array
- Golang program to merge two arrays into third array
- Golang program to reverse an integer array
- Golang program to print the prime numbers from an integer array
- Golang program to search an item in the array using linear search
- Golang program to search an item in the array using binary search
- Golang program to search an item in the array using interpolation search
- Golang program to sort an integer array in ascending order using bubble sort
- Golang program to sort an integer array in descending order using bubble sort
- Golang program to sort an integer array in ascending order using insertion sort
- Golang program to sort an integer array in descending order using insertion sort
- Golang program to sort an integer array in ascending order using selection sort
- Golang program to sort an integer array in descending order using selection sort
- Golang program to add two integer arrays
- Golang program to swap adjacent elements of a one-dimensional array
- Golang program to find the occurrence of an item in the array
- Golang program to find the first repeated element in the array
- Golang program to delete a given item from the array
- Golang program to insert an item in the array
- Golang program to read and print matrix using the two-dimensional matrix
- Golang program to calculate the sum of matrix elements
- Golang program to calculate the sum of rows elements of the matrix
- Golang program to calculate the sum of columns elements of matrix elements
- Golang program to print the Transpose of a matrix
- Golang program to print the left diagonal of the matrix
- Golang program to print the right diagonal of the matrix
- Golang program to print the sum of left diagonal elements of the matrix
- Golang program to print the sum of right diagonal elements of the matrix
- Golang program to add two matrices
- Golang program to multiply two matrices
- Golang program to demonstrate the multidimensional array
Program/Source Code:
The source code to merge two arrays into 3rd array is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt package that includes the files of package fmt then we can use a function related to the fmt package.
In the main() function, we created two arrays arr1 and arr2 initialized with few elements. Then we copy the elements of arr1, arr2 into arr3. After that, we printed the elements of merged array arr3 on the console screen.