HW. i dont understand it


• Write a C++ function double dotProduct(double *px, double *py, int n); that returns the dot product of two integer arrays with starting addresses stored in the pointers px and py. Each array is of size n. Write a main program to test the function dot products using the following dynamically defined arrays:

int x[5]={0,1,2,3,4};
int y[5]={1,2,3,4,5};
(The returned value from the function should be 40)

The dot product for two arrays X and Y is defined as:



Where xi and yi are the ith elements for array x and y respectively.
i=0,1,…,n-1. Please note that accessing the array elements must be done using the pointer/offset notation
Topic archived. No new replies allowed.