| Author: Anonymous | Language: cpp |
| Description: No description | Timestamp: 2007-10-17 15:17:31 -0400 |
| View raw paste | Reply |
- void main(){
- int n, i;
- long double pi = 4, d=3;
- cout << "Enter the number of terms you wish take Pi to." << endl;
- cin >> n;
- for (i = 0; i < n; i++){
- if (i % 2 == 0)
- pi = pi - (4/d);
- else
- pi = pi + (4/d);
- d += 2;
- }
- cout << "Pi = " << pi << endl;
- }
| View raw paste | Reply |
