/*This is a simple program to read two vectors and compute their dot products */ #include using namespace std; #define MAX_DIM 10 void readinvalues(double vector1[], double vector2[],int *dimensions) { /*At the top, we just use vector1[] because C knows we want to use */ /*a pointer to the whole array */ int i; do { cout << "How many dimensions do the vectors have?" << endl; cin >> *dimensions; /* We used a pointer to dimensions because we want to be able to send back to the main loop how many dimensions our vector has */ } while (*dimensions>MAX_DIM); for (i=0;i<*dimensions; i=i+1) { cout <<"Enter vector 1, element" << i << endl; cin >> vector1[i]; } for (i=0;i<*dimensions; i=i+1) { cout <<"Enter vector 2, element" << i << endl; cin >> vector2[i]; } return; } double dotproduct(double vector1[],double vector2[],int dimensions) { int i; double dp; dp=0.0; for (i=0;i