#include <stdio.h>
Go to the source code of this file.
|
| int | main (int argc, char *argv[]) |
◆ main()
| int main |
( |
int | argc, |
|
|
char * | argv[] ) |
Definition at line 3 of file Ejemplo005.c.
4{
5
6
7
8
9
10 int n, i, s, d;
11 float pi;
12 do{
13 printf("Ingrese el numero de terminos: ");
14 scanf("%d", &n);
15 }while(n<=0);
16 for(i=0, pi=0; i<n; i++)
17 {
18 s = 1-2*(i%2);
19 d = 2*i+1;
20 pi+=(s*1.0/d);
21 }
22 pi*=4;
23 printf("PI = %f\n", pi);
24 return 0;
25}