# include <stdio.h> int main(void) { float sigh, sum=1, term, i; for (i=2; i<=100; ++i) { term=(-1)*(1/i); sum=sum+term; ++i; sigh=1/i; sum=sum+sigh; } printf("%f\n", sum); return 0; }
1 #include <stdio.h> 2 int main() 3 { 4 int i; 5 double s=0; 6 for(i=1;i!=101;++i) 7 { 8 s+=1.0/i; 9 s*=-1; 10 } 11 printf("sum = %f\n",s); 12 return 0; 13 }
#include <stdio.h> main() { double s=0,m,n; int i; for(i=1;i<51;i++) { m=1.0/(2*i-1); n=1.0/(2*i); s=s+m-n; } printf("%lf\n",s); return 0; }
#include <stdio.h> main(){ int a; float b; float c=0; for(a=1;a<=100;a++){ if(a%2==0){ b=-a; } else{ b=a; } c=c+1/b; } printf("%f",c); }