I hope I posted this help request in the correct forum, if not I'll get it right next time around. Any case onto my problem :
The following program is suppose to calculate the dot product of two vectors using three files (two .cpp files and one .h file).
Here is my code up to now :
prac7hw2.cpp (OR Main.cpp file)
#include <iostream>
#include "dotProduct.h"
using namespace std;
int main()
{
int size;
double vectorX[20];
double vectorY[20];
cout << "Please enter the size of the vectors: ";
cin >> size;
for (int i = 0; i < size; i++)
{
cout << "Please enter a value for element " << i << " of the first vector: ";
cin >> vectorX[i];
cout << "Please enter a value for element " << i << " of the second vector: ";
cin >> vectorY[i];
}
cout << "The result of the dot product is " << dotProduct(vectorX, vectorY, size) << endl;
}
dotProduct.h (Header file)
#ifndef dotProduct_H
#define dotProduct_H
double dotProduct(double vectorX, double vectorY, int size);
You're passing array pointers when you setupt the function to only except individual elements. You need to rewrite the function to except an array. See the last section of this tutorial page: http://www.cplusplus.com/doc/tutorial/arrays/