0

subscripted value is neither an array nor pointer nor vector at line sum+=matrix[i][j]

int matrix(int matrix[],int m, int n)  //function
{
      int sum=0,i,j;           //to add the matrix elements
      for(int i = 0;i< m ; i ++)
      {
         for(int j=0;j<n; j ++)
         {

Blockquote

            sum+=matrix[i][j];   //error
         }
      }
    return sum
}
  • Shouldnt you be passing two dimensional array to your function ?? Like below. int matrix(int matrix[][],int m, int n) Here are some examples already. in java. https://stackoverflow.com/questions/15638550/finding-sum-of-two-dimensional-array-java – Reddymails Feb 25 '22 at 19:39
  • Basic question pointed to some existing answers already in comments for the user. – Reddymails Feb 25 '22 at 19:40

0 Answers0