I have a homework in C++ Intro. and one of it said to convert the following mathematical equation into a C++ code:
x = 10π/(a+b) sin3C+ 3(ln a)(tan C)
where a,b, and C are user-input and C is in degrees.
I've tried it myself and had end up with this:
float x,y,z,a,b,C;
cout<< "Input the a-value: ";
cin>> a;
cout<< "\nInput the b-value: ";
cin>> b;
cout<< "\nInput the C-value: ";
cin>> C;
C = C*3.1416/180;
x = (10*3.1416/a+b)*pow(sin(C),3)+3*log(a)*tan(C);
cout<< "\n The value of x is " << x;
I've tried a=5,b=10, and C=15 and the result of x is 1.57606. I've tried it in a scientific calculator and x became 1.33005. What could be the problem in my code? Thank you!
I'm sorry if there's anything wrong with my post structure because it's my first time to post here and English is not my native language