Question: I dont know how to call the Vector functions in the main like Vector scalar_multiple( Vector v1, double k, Vector s_mult) I want to call

I dont know how to call the Vector functions in the main like Vector scalar_multiple(Vector v1, double k, Vector s_mult) I want to call that in the main and print the results without changing anything in that function?

#include

#include

#include

#include

using namespace std;

struct Vector {

double x;

double y;

};

Vector calc_AddFunct (Vector v1,Vector v2, Vector AddFunct){

AddFunct.x = v1.x + v2.x;

AddFunct.y = v1.y + v2.y;

return AddFunct;

}

Vector calc_difference (Vector v1,Vector v2, Vector differ){

differ.x = v1.x - v2.x;

differ.y = v1.y - v2.y;

return differ;

}

Vector scalar_multiple(Vector v1, double k, Vector s_mult){

s_mult.x = k * v1.x;

s_mult.y = k * v1.y;

return s_mult;

}

double scalar_product(Vector v1,Vector v2){

return v1.x * v2.x + v1.y * v2.y;

}

double magnitude (Vector v1){

return sqrt(v1.x * v1.x + v1.y * v1.y);

}

int main() {

double k = 10;

Vector vec1; vec1.x = 4; vec1.y = 9;

Vector vec2; vec2.x = 3; vec2.y = -1;

cout << "Scalar Multiple = " << scalar_multiple(vec1, k, ) << endl << endl;

cout << "Scalar product = " << scalar_product(vec1, vec2)<< endl << endl;

cout << "Magnitude of Vector 1 = " << magnitude(vec1)<< endl << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!