this is what i have and i can't figure out how to utilize the cout.precision(n). if you have any information on a code please i would appreciate your help a lot. i have to get calculations using double and float. using these calculations of pi. any help is very much appreciatedCode:#include <iostream>
using namespace std;
int main ()
{
int pi1,pi2,count, x=-1, var;
while (count<1000000000){
cout.precision(7);
pi1=1+x(1/var);
var=var+2;
x=x*-1;}
if (pi1==pi2){
count ++;}
return 0;
}
Leibniz ð / 4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 - 1/15 + 1/17 - ...
Euler ð^2 / 6 = 1 + 1/2^2 + 1/3^2 + 1/4^2 + ...
the assignment is at http://cs.ua.edu/114/assignments/program2.htm
Code tags added by Kermi3.