---
title: "Series (2*3/5)+(4*5/7)+… with functions"
subject: "Computer Programming"
chapter: 6
key: "semester_1/computer_programming:series-2x3-over-5-recursive"
source: https://www.bctengineer.com/q/semester_1/computer_programming/series-2x3-over-5-recursive
site: BCT Engineering
---

# Series (2*3/5)+(4*5/7)+… with functions

Computer Programming · Chapter 6: User-Defined Functions

- Asked in: 2067 Asoj, 7 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/series-2x3-over-5-recursive
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-6

## Question

Write code in C to calculate the sum of following series up to n terms specified by the user where n is passed to the function that calculates the sum. Your program should have more than two functions.
(2*3/5) + (4*5/7) + (6*7/9) + ........

## Short answer

The i-th term is (2i)*(2i+1)/(2i+3) computed in float. sumSeries loops i=1 to n, adding term(i). For n=3, the sum is 8.724.

## Answer

**Analysis.** Looking at the series (2·3)/5 + (4·5)/7 + (6·7)/9 + …, the i-th term is

term(i) = (2i)(2i + 1) / (2i + 3)

Check: i = 1 gives 2·3/5, i = 2 gives 4·5/7, i = 3 gives 6·7/9. The sum is term(1) + … + term(n).

The program uses three functions: `main()` reads n, `sumSeries(n)` receives n and adds the terms, and `term(i)` returns one term. The terms are computed in `float` so that the division is not truncated as integer division.

```c
#include <stdio.h>

/* i-th term = (2i)(2i+1)/(2i+3) */
float term(int i)
{
    return (float)(2 * i) * (2 * i + 1) / (2 * i + 3);
}

float sumSeries(int n)
{
    float s = 0;
    for (int i = 1; i <= n; i++)
        s += term(i);
    return s;
}

int main(void)
{
    int n;
    printf("Enter number of terms: ");
    scanf("%d", &n);
    printf("Sum of %d terms = %.3f\n", n, sumSeries(n));
    return 0;
}
```

**Sample run** (n = 3)

Input: `3`

```text
Enter number of terms: Sum of 3 terms = 8.724
```

Verification: 1.2 + 2.857 + 4.667 = 8.724.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is the i-th term of (2*3/5) + (4*5/7) + (6*7/9) + ...?
   A. (2i)(2i+1)/(2i+5)
   B. (2i)(2i+1)/(2i+3)
   C. (i)(i+1)/(i+3)
   D. (2i)(2i-1)/(2i+3)
   Answer: B. For i = 1, 2, 3 this gives 2*3/5, 4*5/7, 6*7/9. (Key point: General term)

2. Why are the terms computed in float?
   A. Because the loop counter must be float
   B. Because int cannot store 2i
   C. Because scanf requires float
   D. To avoid integer division truncating the fractions
   Answer: D. In integer arithmetic 6/5 would give 1, losing the fractional part. (Key point: Why float)

3. How are the functions divided?
   A. main computes terms, sumSeries only prints
   B. main reads n, sumSeries(n) adds the terms, term(i) returns one term
   C. term(n) reads n and sums everything
   D. Only one function is needed since the sum is simple
   Answer: B. The question needs more than two functions and n passed to the summing function. (Key point: Function structure)

4. For n = 3, the sum printed is about
   A. 6.724
   B. 12.0
   C. 4.667
   D. 8.724
   Answer: D. 1.2 + 2.857 + 4.667 = 8.724. (Key point: Sample result)

## Related in Computer Programming

- [GOTO types; sum of series program](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-goto-types-series) — Computer Programming, chapter 11
- [Function definition; sum of two numbers](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afunction-definition-sum-two) — Computer Programming, chapter 6
- [Cosine series up to n terms](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acosine-series) — Computer Programming, chapter 5
- [Complex number sum via functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astruct-complex-sum-function) — Computer Programming, chapter 8
- [Sum of series Σ1/n²](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aseries-sum-1-n-squared) — Computer Programming, chapter 5
- [Sum of two matrices in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-matrix-sum) — Computer Programming, chapter 11

## Related in other subjects

- [C program: sum of two 8-bit BCD numbers](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-bcd-sum-c) — Embedded System, chapter 9
- [8085 ALP: transfer data with more than 3 ones](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-ones-greater-than-3) — Microprocessor, chapter 2
- [T/F: radial more reliable than network](https://www.bctengineer.com/question.md?key=semester_8%2Ftransmission_and_distribution_system_design%3Atf-radial-more-reliable-network) — Transmission and Distribution System Design, chapter 5, asked 2×
- [RE: no more than 3 a's](https://www.bctengineer.com/question.md?key=semester_3%2Ftheory_of_computation%3Are-at-most-3-as) — Theory of Computation, chapter 2
