Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

See example 1 for an example that may help you solve this problem Complete this program, by adding a function called mag( ) to calculate

See example 1 for an example that may help you solve this problem

Complete this program, by adding a function called mag( ) to calculate the magnitude of a vector. You'll need to add a prototype before main( ), and the implementation (header & body) of the function after main( );

reminder: mag = sqrt (x 2 + y 2)

Calling it with something like:

vec_length = mag(x, y);

Code:

#include #include

using namespace std;

// for part a, put your function prototype for mag here!

//............................................................

int main(void) { double x = 0; double y = 0; double v=3.0, w=4.0; double m;

cout << "Please enter the X coordinate: "; cin >> x; cout << "Please enter the Y coordinate: "; cin >> y;

m = mag(x,y); // you need to write this function! cout << "The magnitude of ( "<< x << " , "<< y <<" ) is: " << m << endl; m = mag(v,w); // now get the magnitude of vector (v,w) cout << "The magnitude of ( "<< v << " , "<< w <<" ) is: " << m << endl;

return 0; }

//.................put your mag function here................... // be sure to add comments describing the inputs and outputs so a reader would // know how to use it.

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions