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