Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Distinguish between poor and good positive and neutral messages.

Answered: 1 week ago

Question

Describe the four specific guidelines for using the direct plan.

Answered: 1 week ago