Code Golf: Leibniz Series This is the same question as Solve the CodeSprint4 Leibniz code golf challenge in Python in 66 characters. The variation is that I'm a C programmer. My code for the above question is:

#include &lt;math.h&gt;
main(){  
int i,t,p;  
scanf("%d",&amp;t);  
while(t--)  
{  
double s=1;  
scanf("%d",&amp;p);  
for(i=1;i&lt;p;++i)  
s+=pow(-1,i)/(2*i+1);  
printf("%.12lf\n",s);  
}  
} 


Now I just need to know the places where I could reduce my code length.
Do everything in one line.
Don't read number of test cases, scanf will return -1 on EOF
Don't include anything, pow(-1,i) can be replaced by 1-i%2*2
Do the sum loop in reverse to save a variable.


Here is my 102 bytes code

main(n){gets(&amp;n);for(double s;s=scanf("%d",&amp;n)&gt;0;printf("%.15f\n",s))while(--n)s+=(1-n%2*2)/(1.+2*n);}