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 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:
inputs and outputsan algorithm or descriptionrelationship between inputs and outputs
Problem points: Threedimensional vector calculation
Given a vector V its magnitude is calculated as
Given two vectors V and V
the dot product is
the angle in degrees between the two vectors is
Use for
Write an interactive C program that
display options for vector calculation that a user can choose
ask a user for an option Mm for finding the magnitude, Dd for finding the dot product and angle between the two vectors, Qq 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:
findmagnitude accepts input arguments and returns the vector magnitude double findmagnitudedouble Vx double Vy double Vz;
For the function below, see zyBooks section pass by pointers
finddotprodangledeg accepts vectors and outputs the dot product and angle in degrees between two vectors void finddotprodangledegdouble Vx double Vy double Vz double Vx double Vy double Vz double dotprod double angledeg;
In the main code, let's assume it has doubletype variables Vx Vy Vz Vx Vy Vz outputdotprod, outputangledeg, the function above is called with
finddotprodangledegVx Vy Vz Vx Vy Vz &outputdotprod, &outputangledeg;
Sample code execution :
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 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: magnitude of is 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 Vx Vy Vzseparated by spaces: Enter Vx Vy Vzseparated by spaces: dot is angle between these vectors is degrees 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: magnitude of is 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 :
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 Vx Vy Vzseparated by spaces: Enter Vx Vy Vzseparated by spaces: dot is angle between these vectors is degrees 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: magnitude of is 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 Vx Vy Vzseparated by spaces: Enter Vx Vy Vzseparated by spaces: dot is angle between these vectors is degrees 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
