Multiply matrix by array in c

3

I am trying to multiply an array of random numbers by an array of random numbers and I get the following error:

  

invalid operands to binary * (have 'int *' and 'int')

I do not understand where the error comes from since I'm not using pointers.

The error is given to me in the multiplication operation (which is below the whole):

void main()
{
    int m = 5;
    int n = 4;
    int A[m][n];
    int x[n];
    int y[m];
    int i, j;

    srand(time(NULL));
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            A[i][j] = 1 + (rand()%999);
            x[i] = 1 + (rand()%999);
            y[j] = 0;
        }
    }

    for(i=0; i<m; i++) {
        for(j=0; j<n; j++){
            y[m] = A[i] * x[j];
        }
    }
}
    
asked by Juanker 02.11.2017 в 14:49
source

1 answer

2

A is a two-dimensional array ... you need to indicate the second dimension:

for(i=0; i<m; i++) {
    for(j=0; j<n; j++){
        y[m] = A[i][j] * x[j];
//                 ^^^
    }
}
    
answered by 02.11.2017 / 14:51
source