Created
March 1, 2011 00:14
-
-
Save javier-lopez/848342 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/*#pragma hdrstop*/ | |
#include <string.h> | |
#include <stdlib.h> | |
//--------------------------------------------------------------------------- | |
/*#pragma argsused*/ | |
int main(int argc, char *argv[]) | |
{ | |
int contador, n=0; | |
float x,suma; | |
printf ("Ingresa el numeno de elementos a sumar: "); | |
scanf("%i",&n); | |
suma=0; | |
x=-1; | |
for(contador=1; contador<=n; contador++) | |
{ | |
if((contador%2)==0) | |
{ | |
suma=(suma -(1/(2+x))); | |
} | |
else if ((contador%2)!=0) | |
{ | |
suma=(suma +(1/(2+x))); | |
} | |
x=x+2; | |
} | |
printf("%f",suma); | |
printf("\n\n\n"); | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment