series program in c

series program in c
write a program to print follwing series sum
1/2 - 2/3 + 3/4 - 4/5 + 5/6 - ...... n


#include<stdio.h>
int main()
{
    double j, n,sum=0;
    n=10;
    for(j=1;j<=n;j++)
    {
        if ((int)j%2==1)
            sum+=j/(j+1);
        else
            sum-=j/(j+1);
    }
    printf("Sum: %lf",sum);
}
Copyright © C Program | Java | OpenGL Programming | Hadoop at Computaholics