#include <stdio.h> int main() { int i, n; double sum; n = 1000; sum = 0.0; for (i = 1; i <= n; i=i+1) sum = sum + 1/((double)i*(double)i); printf("Sum of %d terms is %lf\n",n,sum); }
#include <stdio.h> int main() { int i, n; double x, sum; n = 1000; sum = 0.0; for (i = 1; i <= n; i=i+1){ x = 1/(double)i; sum = sum + x*x*x; } printf("Sum of %d terms is %lf\n",n,sum); }