Mar 2, 2013 at 8:09pm UTC
Before looking at the program a stupid question: are you using degrees or radians?
Mar 2, 2013 at 8:11pm UTC
Not so stupid question, the answer is default :S I have no idea how to change it.
Thanks for the quick response!
Last edited on Mar 2, 2013 at 8:12pm UTC
Mar 2, 2013 at 8:13pm UTC
Is there any particular reason why starting on line 26 there is another curly parantheses block?
Mar 2, 2013 at 8:14pm UTC
The angles in C use radians because it's faster to calculate it that way. If you want to use degrees you'll have to convert it.
EDIT: Faster, or easier as the case my be.
Last edited on Mar 2, 2013 at 8:15pm UTC
Mar 2, 2013 at 8:20pm UTC
http://en.wikipedia.org/wiki/Radians
Well, a full-circle angle in degrees is 360 degrees, right?
A full-circle angle in radians is 2 pi radians.
So to convert from radians to degrees multiply by (360 / 2 pi).
To convert from degrees to radians multiply by (2 pi / 360).
Last edited on Mar 2, 2013 at 8:21pm UTC
Mar 2, 2013 at 8:34pm UTC
45 degrees is 1/4 pi, 30 degrees is 1/6 pi.
Mar 2, 2013 at 9:27pm UTC
Sorry, I am really having trouble converting the units correctly. I've been trying to figure it out for a while and I still can't seem to do it. Any ideas?
Mar 2, 2013 at 10:43pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include <iostream>
#include <cmath>
using namespace std;
const double pi = 3.1415926535897932385;
int main()
{
double degrees = 30;
double radians = degrees * pi / 180.0; // Convert degrees to radians
cout << "the sine of " << degrees
<< " degrees is " << sin(radians) << endl;
double num = sqrt(3)/2.0;
radians = asin(num);
degrees = radians * 180.0 / pi; // Convert radians to degrees
cout << "The angle whose sine is " << num
<< " is " << degrees << " degrees" << endl;
return 0;
}
Output:
the sine of 30 degrees is 0.5
The angle whose sine is 0.866025 is 60 degrees
Last edited on Mar 2, 2013 at 10:45pm UTC