Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to do a while loop for would you like to perform another code. Plase help me fix my programs. My code is not

I want to do a while loop for would you like to perform another code. Plase help me fix my programs. My code is not working, I am so confused.image text in transcribed

double Magn(double V[]) { double m; m = sqrt(V[0] * V[0] + V[1] * V[1] + V[2] * V[2]); return m; }

double Dotp(double V1[], double V2[]) { double dotp; dotp = V1[0] * V2[0] + V1[1] * V2[1] + V1[2] * V2[2]; return dotp; }

double Ang(double dotp, double m1, double m2) { double angle; angle = acos(dotp / (m1 * m2)) * 180 / 3.1415926; return angle; }

void CrossP(double V1[], double V2[], double crossp[]) { crossp[0] = V1[1] * V2[2] - V1[2] * V2[1]; crossp[1] = -V1[0] * V2[2] + V1[2] * V2[0]; crossp[2] = V1[0] * V2[1] - V1[1] * V2[0];

}

int main(void) { double V1[3]; double V2[3]; double m1; double m2; double dotp; double crossp[3]; double angle; char flag = 'a'; char YN = 'y'; int i;

while (YN=="y") { printf("Enter M to calculate the magnitude of a single 3-D vector "); printf("Enter D to calculate the dot product of two 3-D vectors "); printf("Enter C to calculate the cross product of two 3-D vectors "); scanf("%c", &flag);

if (flag == 'M') { printf("Enter in Vx Vy Vz (separated by spaces) ");

for (i = 0; i | = %lf ", V1[0], V1[1], V1[2], m1); }

if (flag == 'D') { printf("Calculating the dot product between V1 and V2 "); printf("Enter in Vx1 Vy1 Vz1 (separated by spaces) "); for (i = 0; i

printf("V1 dot V2 = %lf, theta = %lf degrees", dotp, angle); }

if (flag == 'C') { printf("Calculating the dot product between V1 and V2 "); printf("Enter in Vx1 Vy1 Vz1 (separated by spaces) "); for (i = 0; i , theta = %lf degrees", crossp[0], crossp[1], crossp[2], angle); }

printf("Would you like to perform another calculation? (y)"); scanf("%c", &YN);

} return 0;

}

Sample Code Execution: Red text indicatesi Enter M to calculate the magnitude of a single 3-D vector Enter D to calculate the dot product of two 3-D vectors Enter C to calculate the cross product of two 3-D vectors Enter in Vx Vy Vz (separated by spaces) 1 2 3 Ivi = !| 3.74165739 Would you like to perform another calculation? (y)j Enter a valid input Would you like to perform another calculation? (y)y Enter M to calculate the magnitude of a single 3-D vector Enter D to calculate the dot product of two 3-D vectors Enter C to calculate the cross product of two 3-D vectors Enter a valid choice Enter M to calculate the magnitude of a single 3-D vector

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago