hi all
i have a problem and i hope someone will help me.
i have this program and i want to find the absolute maximum difference between y1 and y2 ??!!
i have found the difference between y1 and y2 but i could not find the maximum difference between them!!!
I mean the maximum difference for all the numbers .
for example, if we have
y2-y1=23
y2-y1=20
y2-y1=12
y2-y1=40
then the maximum difference = 40
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main()
{
//Declaration and Initialization
const double e=2.718282;
int random,i(1);
double y1,y2;
double r;
cout<<"Enter the number of random values to be entered: ";
cin>>random;
cout<<"\n\nx\t"<<"exact root(y1)\t"<<"estimated root(y2)\t"
<<" The differnce between roots"<<"\n";
while(i<=random)
}
r=rand()%((20000/1000)-(5000/1000))+5000/1000;
y1=sqrt(r);
y2=e*(.5*log(r));
cout<<setprecision(3)<<r<<"\t"<<setprecision(6)<<y1<<" \t"<<setprecision(6)
<<y2<<"\t"<<setprecision(6)<<" "<<fabs(y2-y1)<<endl;
i++;
}
return 0;
}