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.  
  12. for (int i = 1; i <= n; i++) {
  13. sum += 1.0 / (i * (i + 1));
  14. }
  15.  
  16.  
  17. printf("Sum of the first %d terms of the series: %.4f\n", n, sum);
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5276KB
stdin
3
stdout
Enter the value of n: Sum of the first 3 terms of the series: 0.7500