I need help with a code from my beginner course. This code is to calculate the conductivity of a substance. The formula I am using is lamda = 75βsin(4.5π€)/(350βπ) where 4.5w should be in degrees. The code I entered should output 0.57 when T=250 and w=11, but the result I keep getting is 0.49. I have no idea why this is happening, any help is appreciated!
1 2 3 4 5 6 7 8 9 10 11
constdouble PI = 3.14159265;
float lam;
double w, T;
cout << "Please enter weight percent of beryllium" << endl;
cin >> w;
cout << "Please enter the temperature of the substance" << endl;
cin >> T;
lam = 75 / (350 - T) * sin(4.5 * w * 180 / PI);
cout << lam << endl;
system ("pause");
return 0;
You are converting to radians incorrectly. It should be:
double radians = degrees / 180.0 * PI;
And lam should probably be double.
BTW, you're mixing spaces and tabs for your indentation. That's a no-no! Overall it's probably best to set your editor to insert 4 spaces instead of actual tabs.