Question: Write comments in your programs, otherwise 2 points will be deducted. For each program, the following info should at least be included at the top

Write comments in your programs, otherwise 2 points will be deducted. For each program, the following info should at least be included at the top of the C file:
Author and Date created
Brief description of the program:
input(s) and output(s)an algorithm (or description/relationship between inputs and outputs)
Problem 2(35 points): Three-dimensional vector calculation
Given a vector V =, its magnitude is calculated as
Given two vectors V1= and V2=,
the dot product is
the angle (in degrees) between the two vectors is
Use 3.14159 for .
Write an interactive C program that
display options for vector calculation that a user can choose
ask a user for an option (M/m for finding the magnitude, D/d for finding the dot product and angle between the two vectors, Q/q to Quit)
ask a user for one vector or two vectors (depending on the option)
find and display the calculation
Your C program must use the following user defined function:
// find_magnitude accepts 3 input arguments and returns the vector magnitude double find_magnitude(double Vx, double Vy, double Vz);
For the function below, see zyBooks section 6.2- pass by pointers
// find_dotprod_angledeg accepts 2 vectors and // outputs the dot product and angle in degrees between two vectors void find_dotprod_angledeg(double Vx1, double Vy1, double Vz1, double Vx2, double Vy2, double Vz2, double *dotprod, double *angle_deg);
In the main code, let's assume it has double-type variables Vx1, Vy1, Vz1, Vx2, Vy2, Vz2, outputdotprod, outputangledeg, the function above is called with
find_dotprod_angledeg(Vx1, Vy1, Vz1, Vx2, Vy2, Vz2, &outputdotprod, &outputangledeg);
Sample code execution 1:
3-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: A wrong option entered 3-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: M Enter Vx Vy Vz (separated by spaces): 123.3 magnitude of <1.00,2.00,3.30> is 3.98623-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: D Enter Vx1 Vy1 Vz1(separated by spaces): 123.3 Enter Vx2 Vy2 Vz2(separated by spaces): 7.114.223.43<1.00,2.00,3.30> dot <7.10,14.20,23.43> is 112.8190 angle between these 2 vectors is 0.0000 degrees 3-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: m Enter Vx Vy Vz (separated by spaces): 7.114.223.43 magnitude of <7.10,14.20,23.43> is 28.30223-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: q Good Bye
Sample code execution 2:
3-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: d Enter Vx1 Vy1 Vz1(separated by spaces): 123.3 Enter Vx2 Vy2 Vz2(separated by spaces): 117.7-8<1.00,2.00,3.30> dot <11.00,7.70,-8.00> is 0.0000 angle between these 2 vectors is 90.0001 degrees 3-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: m Enter Vx Vy Vz (separated by spaces): 345 magnitude of <3.00,4.00,5.00> is 7.07113-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: D Enter Vx1 Vy1 Vz1(separated by spaces): 345 Enter Vx2 Vy2 Vz2(separated by spaces): -5.41.56<3.00,4.00,5.00> dot <-5.40,1.50,6.00> is 19.8000 angle between these 2 vectors is 70.0592 degrees 3-D Vector calculation Enter M or m to find the magnitude Enter D or d to find the dot product and angle in degrees Enter Q or q to Quit Enter your choice: Q Good Bye

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 Programming Questions!