Error
Hiya!Please someone help me why my variable 'e' is not being initialized? Im kinda new to C++. Thanks, guys!
Here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
#include <iomanip>
using namespace std;
#include <cmath>
int main ()
{
double a,b,c,d,e,f,g,i,t,x;
double max=50.0;
cout<<"Enter tolerance: ";
cin>>x;
for (i=0,a=-2.0,b=-1.0,t=0; i>max; i++)
{
c=a*a*a-3*a-1;
d=b*b*b-3*b-1;
e=(b*c-(a*d))/(c-b);
f=e-t/e;
if (c*e > 0)
{
a=c;
}
else
{
b=e;
}
if (f < x)
{
break;
}
else
{
t=f;
}
}
cout<<e;
system ("pause");
return 0;
}
|
Topic archived. No new replies allowed.