I am trying to get the value of sin based on an angle input from the user. The program changes the angle from degrees to radians. Then uses the formula:
sin(x) = x − x^3/3! + x^5/5! - x^7/7! + x^9/9!...
It does this all the way to 15. When I try to compile my program it says it doesn't evaluate to a function. Here is what I have so far:
sin(x) = x − x^3/3! + x^5/5! - x^7/7! + x^9/9!...
It does this all the way to 15. When I try to compile my program it says it doesn't evaluate to a function. Here is what I have so far:
Code:
#include <iostream>
#include <math.h>
using namespace std;
#define PI 3.14
int main()
{
float angle,radian,sine,n,x,factorial;
cout<<"Enter angle in degrees (0 to quit): ";
cin>>angle;
while (angle!=0){
radian=angle*(PI/180);
sine=0;
n=1;
while (n<=15){
sine=(x-(pow(x,n))/(factorial(n)));
n++;
}
cout<<"Sine equals: "<<sine<<endl;
return 0;
}
}
Comment