fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. double sum = 0.0;
  6.  
  7.  
  8. printf("Enter the value of n: ");
  9. scanf("%d", &n);
  10.  
  11. for (int i = 1; i <= n; i++) {
  12. sum += 1.0 / (i * (i + 1));
  13. }
  14.  
  15. printf("Sum of the first %d terms of the series: %.4f\n", n, sum);
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
Enter the value of n: Sum of the first 32764 terms of the series: 1.0000