- Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathPI.cpp
More file actions
Latest commit
25 lines (25 loc) · 739 Bytes
/
Copy pathPI.cpp
File metadata and controls
25 lines (25 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/****************
*Finding PI to the Nth Digit
*By Tom Biju
****************/
#include<iostream>
#include<iomanip>//for setting precision
#include<stdlib.h>
usingnamespacestd;
//Program to find PI to a specified number of decimal places
intmain(int argc, char* argv[]){
doublePI=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
int decimalPlaces;
char* commandLine=argv[1];
if(commandLine==NULL){
cout<<"Enter how many decimal places of PI you would like to see (limit 100): "<<endl;
cin>>decimalPlaces;
decimalPlaces+=1;
}
else{
decimalPlaces=atoi(commandLine);
decimalPlaces+=1;
}
cout<<setprecision(decimalPlaces)<<PI<<endl;
return0;
}