I'm sorry to be taking up some of your valuable time. I'm just a beginner programmer and was trying to compile a relatively simple code (for you guys). In my opinion, I have got my functions right, but my function 'output' 's declaration is causing some issues and I'm finding it difficult to find out what did I do wrong. There is a warning indicated by the compiler in lines 41 and 50 and I have highlighted it in my program. I'd really appreciate it if you could point out my error.
#include<simplecpp>
#include<cmath>
#define pi 3.1415926535897932384626433832795
class calculation{
private:
int i=1;
double t0=1;
double t1,R,sum=1;
double precision,degrees,radian,cosx;
public:
void getValue();
void radians();
double cosf(double radian);
void output();
};
void calculation::getValue(){
cout<<"Enter Angle: ";
cin>>degrees;
cout<<"Enter Precision: ";
cin>>precision;
}
void calculation::radians(){
degrees=abs(degrees);
radian=(degrees*pi)/180;
}
double calculation::cosf(double radian){
{
do{
R=-(radian*radian)/(2*i-1)/(2*i);
t1=R*t0;
sum=sum+t1;
t0=t1;
i++;
}
while(abs(t1/sum)>precision);
return sum;
}
}
void calculation::output(){
double cosx = cosf(radian);
cout<<"cosine of the angle will be: "<<cosx;
}
int main(){
calculation o1;
o1.getValue();
o1.radians();
double radian=0;
o1.cosf(radian);
o1.output();
}
EDIT: I made the necessary changes (as suggested by @NotAProgrammer), but while compiling, cos x is still showing the value as 1. Could you please help me out?