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