Hey guys, I'm working on a project that requires the user to determine how many numbers are after the decimal place in PI, defined as 3.1415926535897
Here is my work:
//Mike Karbowiak 9/19/13
//This program has the user format PI, meaning he or she chooses how many deciaml places PI should be. (i.e. tenths, hundredths, etc.)
/*Mike Karbowiak 9/19/13
This program has the user format PI, meaning he or she
chooses how many deciaml places PI should be.
(i.e. tenths, hundredths, etc.)*/
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <cwchar>
#define PI 3.1415926535897
usingnamespace std;
int main () {
int input;
cout<< "Hello, today you are going to format PI. \n" <<endl;
cout<< "Remember.. PI is 3.1415926535897 ... \n" <<endl;
cout<< "Now that you understand PI to a few\n"
<< "numbers where would you like the numbers to end?\n" <<endl;
cin >> input;
cout << endl;
cout.setf(ios::fixed, ios::floatfield);
cout << "This is PI: " << PI <<endl;
cout<<endl;
cout.precision(input);
cout<< "This is PI according to you: " << PI << endl;
return 0;
}
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <cwchar>
#include <limits>
#define PI 3.1415926535897
usingnamespace std;
int main () {
int input;
cout<< "Hello, today you are going to format PI. \n" <<endl;
cout<< "Remember... PI is 3.1415926535897... \n" <<endl;
cout<< "Now that you understand PI to a few\n"
<< "numbers where would you like the numbers to end?\n" <<endl;
cin >> input;
cout.precision(numeric_limits<double>::digits10);
cout << "This is PI: " << PI <<endl;
cout<<endl;
cout.precision(input);
cout<< "This is PI according to you: " << PI << endl;
return 0;
}