how do i make a program that calculates the product of two vectors in C ?

this is what i have but i think im doing it wrong i need some help?

``````#include <stdio.h>
double inner(double m[ ] , double n[ ] , int size ) ;
int main( int argc, char *argv[ ] ) {

int i,k ;

double m , n ;

for(i = 0 ; i < 8 ; i++ ) {

printf("Please enter a number for m :") ;
scanf("%lf",&m[i]) ;
}
for(k=0 ; k < 8 ; k++ ) {

printf("{{lease enter a number for n :") ;
scanf("%lf",&n[i]) ;
}

printf("The inner product of the two vectors is : %lf ",inner(m,n,8 ) ) ;

return 0 ;

}

double inner(double m[ ] , double n[ ] , int size ){

int j ;
double sum = 0.0 ;

for( j = 0 ; j < size-1 ; j++){

sum =+ (m[j] * n[j]) ;

}

return sum ;

}``````

Your inner() function doesn't multiply the last set of values. On line 33, the loop termination should be j < size.

That's the only issue that comes to mind; assuming your inner product algorithm is correct.

i meant calculating the inner product of two vectors , I dont think my inner function is correct thats why I need help with it :(

Ah ... well, that one's a math question. From a quick scan of Wikipedia, I believe your algorithm is right (except for the fencepost error at the end). You might want to check that part on a math forum...