Question: Use C Create a function that will take in a vector (three double variables) representing a position in meters. Calculate the magnitude of the vector

Use C

Create a function that will take in a vector (three double variables) representing a position in meters.

Calculate the magnitude of the vector in meters:

sqrt(x * x + y * y + z * z)

Calculate the magnitude of the vector in feet:

magnitudeInMeters * 3.28084

Using passing by reference, return both outputs from the same function.

Input: Three unique doubles, each one representing a component of the vector.

Output: Magnitude of the vector in meters, magnitude of the vector in feet.

TIP: You will need to #include to use the square root function (sqrt).

TIP: You need to use pointers and pass by reference to output both values from the same function.

In your main function:

Prompt the user to enter the X component in meters, followed by the Y component, followed by the Z component.

Call your magnitude calculating function and receive both outputs.

Output the magnitude of the vector in meters.

Output the magnitude of the vector in feet.

NOTE: Your function is required to demonstrate pass by reference

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!