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[8] , n[8] ;
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 ;
}