Skip to content

Instantly share code, notes, and snippets.

@javier-lopez
Created March 1, 2011 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javier-lopez/848342 to your computer and use it in GitHub Desktop.
Save javier-lopez/848342 to your computer and use it in GitHub Desktop.
#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