Heres the program:
#include
using namespace std;
int main()
{
long double pi=4.00;
bool op=false;
for (long double n=3.00;n<1000000.00;n+=2.00)
{
if (op==true)
{pi+=4.00/n; op=false;cout << pi << endl;}
else
{pi-=4.00/n; op=true; cout << pi << endl;}
}
system ("PAUSE");
return 0;
}
it returns more and more accurate approximations of pi, but it only returns 6 digits, doesnt long double have a precision of 19 digits??
i need it to output more digits after the decimal
2007-03-02
12:32:43
·
3 answers
·
asked by
Pandu
2
in
Computers & Internet
➔ Programming & Design