Help on c++ (how to round correctly the pi value)
Help on c++ (how to round correctly the pi value)
thank you very much guys...
my problem is fixed...
here is the code for the first series.......
for (int long n=1; n<=10000 && flag!=1; n++) //for loop for series 1 {//star for loop series 1 pi1+= (4*pow(-1.0, n+1))/(2*n - 1); //calculation series 1 pi12=ceil((pi1*pow( 10.0,digits ) )- 0.49 ) / pow( 10.0,digits ); //round the results if (pi12==result) //if check..... for the result {//if check start flag=1; // if pi12==result flag== 1 }//if check end else //else of the result counter++; // if the program don't find the approximate series change iterations ( calculation of iteratios) }//loop end series 1 if (flag==1) // if check = 1 { // start if cout<<" Series "<<series<<" is approximate on "<<counter<<" iterations"<<" Series "<<series<<" is "<<pi12<<endl; cin>>pi12; //cin the result to print } // if end else // else of check cout<<" This series doesn't approximate on Value PI...."<<endl; //print error message.... cin>>pi;//cin the result to print }//end of if staytment series 1
Login