When I compile the program it returns "error C2065: 'answer' : undeclared identifier". I thought answer was declared from the function and would call answer. Any tips where I'm going wrong on this. The program is made to out put Radius, cosx(x), and a user defined cosx in 3 rows.
double cosx (int x, int answer);
int main ()
{
for (double x = 0.0; x <= 3.1; x = x + .1)
{
cout << "Radians" << setw(6) << "Cousines by cos(x)" << setw(15) << "Cousines by user defined" << endl;
cout << setprecision(2) << fixed << x << setw(6) << cos(x) << setw(15) << cosx (x, answer) << endl;
}
}
double cosx (int x, int answer)
{
int n, num, denom, ans, term, count;
n = 2;
while (ans >= .000001)
{
for (int i = 0; i <= n; n++)
{
num = num*n;
}
for (int k = num; k >= 1; k--)
{
denom = denom*k;
}
term = num/denom;
if ((term%11)== 0)
ans = ans + term;
else
ans = ans - term;
count++;
n+= 2;
}
return ans;
}