Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void) {
- double out = 0.0;
- int i;
- double placeholder = 1.0;
- int parity = 0;
- for(i=3; i <= 99; i+=2) {
- if(parity == 0) {
- placeholder = placeholder - (1.0/i);
- parity = 1;
- }
- else if(parity == 1) {
- placeholder = placeholder + (1.0/i);
- parity = 0;
- }
- }
- out = 4.0*placeholder;
- printf("pi is approximately equal to %f", out);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement