I've started programming 1 week ago and I use win32 console for an output.
In program which calculates pi:
Code:
The output is:Code:#include <iostream> #include <math.h> using namespace std; int main() { double b=-1; double pi=acos(b); cout << pi << endl; system("PAUSE"); return 0; }
Output:
I know that computer calculated pi with much higher precision, so how do I get, I don't know... 15 digits on the output screen?Code:3.14159
One more related question. I'm trying to write a random number generator program, since I've noticed that the rand() function doesn't have the uniform distribution of random number values, and for that I need a function that would "cut" double variable started from some decimal value to some other decimal value. For example, if I have a double variable number pi=3.141592654... I want a new integer variable with value from 3rd to 6th digit, int a=592. How do I do that?
The final question. If I want to test relationship between many output variables it would be very usefull if program could put these values in a txt file. How do I do that? Remember (I don't know if that maters) I'm programming (or trying to), that is, the output is in win32 console.
Thank you!



LinkBack URL
About LinkBacks
), that is, the output is in win32 console.


