Currently I am trying to implement this formula pi = n*(sin(180/n)); in xcode. But just writing it like this gives me huge numbers like -12425553 or 23082083. How can I fix it??
I used int n; double pi;.
Update:
I tried using M_PI/180 to convert to degrees but it still doesn’t work. Any suggestions??
pi = n*sin((180/n) * (M_PI/180));
By the way I removed the asterisks!!
There are three problems with your code:
sintakes degrees (it takes radians)sinindeed took degrees, which it does not, you should have used180.0in place of180)To convert degrees to radians, use this formula: