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
closed account (48T7M4Gy)
You have to write a program that does:

dot_product = x[0]*y[0] + x[1]*y[1] + ... + x[5]*y[5]

But, instead of x[5] etc you have to use pointers to the numbers in the array

Topic archived. No new replies allowed.