GO Program to implement array multiplication program

How to implement array multiplication program

Here we are explaining how to implement an array multiplication program in the Go program. We can use the built-in function fmt.println() to print anything and fmt.scanln() for reading the values. This function is defined under the fmt package and it helps to write standard output. In order to use these functions, we need to import the “fmt” package.


How to implement array multiplication program using GO Program

We are using fmt.println() function for printing the string to the output screen. Here we are showing how to implement an array multiplication program in the Go language. Here variable Arr1,Arr2,MArr holds the array elements. Another variable i used as the index for the loop. Use for loop to find the array multiplication by iterating through the loop. Multiplication is done as (Arr1[i] * Arr2[i]) and stored it to new array MArr. Given below are the steps which are used in the Go program. 


STEP 1: Import the package fmt

STEP 2: Start function main()

STEP 3: Declare the variable i

STEP 4: Read the arrays Arr1[], Arr2[] using for loop

STEP 5: Find the array multiplication in a for loop as  Arr1[i] * Arr2[i]

STEP 6: Store the result into an array MArr and continue the loop

STEP 7:Print the result array MArr using fmt.Println()


GO Source Code

                                          package main
import "fmt"

func main() {
    var i int
    var Arr1 [5]int
    var Arr2 [5]int
    var MArr [5]int

    fmt.Print("Enter the first array items = ")
    for i = 0; i < 5; i++ {
    fmt.Print("Enter the second array items = ")
    for i = 0; i < 5; i++ {

    fmt.Print("The multiplication of two arrays = ")
    for i = 0; i < len(MArr); i++ {
        MArr[i] = Arr1[i] * Arr2[i]
        fmt.Print(MArr[i], "  ")


Enter the first array items = 1 2 3 4 5
Enter the second array items = 5 6 7 8 9
The multiplication of two arrays = 5  12  21  32  45