Panic: runtime error index out of range

Hmm, I am learning a golang

Here I created programm for matrix multiplication which has given me error

Here’s Is Code

1 Like

You should allocate memory for your matrix.


Something like :

MATA = make(int[][], R1)
fmt.Println("Enter Values For Matrix A \n\n")
for i := 0; i < R1; i++ {
   MATA[i] = make(int[], C1)
   for j := 0; j < C1; j++ {
      fmt.Print("Enter [", i+1, "][", j+1, "] Element:\t")
      fmt.Scanf("%d", &MATA[i][j])

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.