// Calculating dot product of two vectors
#include <iostream>
using namespace std;

// Returns dot (scalar) product of two vectors of size n
double dotProd(double a[], double b[], int n = 1)
{
  double dp = 0.0;
  for(int k=0; k<n; ++k)
    dp += a[k]*b[k];
  return dp;
}

int main ()
{
  const int size = 3;
  double v1[size], v2[size];

  cout << "Enter the components of\n";
  cout << "the first  vector: ";
  for(int j=0; j<size; j++) cin >> v1[j];
  cout << "the second vector: ";
  for(int j=0; j<size; j++) cin >> v2[j];

  double dot = dotProd(v1, v2, size);

  cout << "dot product of the vectors: "
       << dot << endl;

  return 0;
}
