Below is some code that I am trying to write for my class. I have the dot product worked out. Cross product is giving me some trouble. Having trouble understanding the error I get:
invalid conversion from 'int*' to 'int'
#include <iostream>
#include <string>
using namespace std;
int A[3];
int B[3];
int length = 3;
int cross[3];
int dotProduct (int A[], int B[]){
int product = 0;
for (int i = 0; i < length; i++)
{
product = product + A[i] * B[i];
}
return product;
}
int crossProduct(int A[], int B[], int cross[]){
cross[0]=A[1] * B[2]-A[2] * B[1];
cross[1]=A[2] * B[0]-A[0] * B[2];
cross[2]=A[0] * B[1]-A[1] * B[0];
return cross;
}
int main (){
cout << "Please enter the coordinates for vector A: " << endl;
cout << "X: ";
cin >> A[0];
cout << endl << "Y: ";
cin >> A[1];
cout << endl << "Z: ";
cin >> A[2];
cout << endl;
cout << "Please enter the coordinates for vector B: " << endl;
cout << "X: ";
cin >> B[0];
cout << endl << "Y: ";
cin >> B[1];
cout << endl << "Z: ";
cin >> B[2];
cout << endl;
cout << "Dot Product is: " << dotProduct (A, B) << endl;
crossProduct (A, B, cross);
cout << "Cross Product is: ";
for (int i=0;i<length;i++){
cout << crossProduct[i]<<" ";
}
return 0;
}