I had an algorithm written up that worked perfectly, except my professor wants it to call on a function which i didnt do. So i tried to change it and im not sure what im doing wrong.
#include <iostream>
#include <cmath>
using namespace std;
double func(double angrad);
// this is the function i want to call on.
int main () {
int angle, n;
long double angrad, numerator=1, denominator=1, cosine=1, temp=0, pi=3.14159;
cout << "Input an angle in degrees between 0 and 90: \n";
cin >> angle;
angrad = pi*angle/180;
// angrad is the angle in radians.
for (n=0; n <= 10; n++) {
cosine = cosine + temp;
numerator = -numerator*angrad*angrad;
denominator = (n+2)*(n+1)*denominator;
temp = numerator/denominator;
cout << "The cosine function in the cmath library for this angle is: " << cos (angrad) << endl;
}
return 0;
}
double func(double angrad);
// here i try to call the function
}
cosine = cosine+temp;
return cosine;
}
i know the mistake is probably stupid/noobish but im still not very good at c++.
1. No where in main is func called.
2. func doesn't make use of angrad, so the use of a parameter is superfluous.
3. You've got a closing brace '}' where there should be an opening brace '{'.