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 <math.h>
main(){
int i,t,p;
scanf("%d",&t);
while(t--)
{
double s=1;
scanf("%d",&p);
for(i=1;i<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.
#include<stdio.h>
\$\endgroup\$#include
@CoolGuy. Most C compilers will complain but compile nevertheless. \$\endgroup\$p
terms,t
times - is that right? \$\endgroup\$