---
title: "Sum of series Σ1/n²"
subject: "Computer Programming"
chapter: 5
key: "semester_1/computer_programming:series-sum-1-n-squared"
source: https://www.bctengineer.com/q/semester_1/computer_programming/series-sum-1-n-squared
site: BCT Engineering
---

# Sum of series Σ1/n²

Computer Programming · Chapter 5: Control statements

- Asked in: 2072 Kartik, 5 marks
- Video: [2.4 Summation of Series Using For Loop in C Programming](https://www.youtube.com/watch?v=aJASzYhtARU) — Apna Tuition
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/series-sum-1-n-squared
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-5

## Question

Write a program to find the sum of series Sn = Σ 1/n² up to N term.

## Short answer

Sum 1/i^2 for i=1 to N using double (1.0/(i*i)). With N=10, the result is 1.549768.

## Answer

The series is Sn = 1/1² + 1/2² + 1/3² + ... + 1/N². The program adds `1/(i*i)` for `i = 1` to `N`. A `double` and the real constant `1.0` are used so that the division is not an integer division (which would give 0).

```c
#include <stdio.h>
int main(void)
{
    int n, i;
    double sum = 0.0;
    printf("Enter number of terms: ");
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
        sum += 1.0 / ((double)i * i);
    printf("Sn = %.6f\n", sum);
    return 0;
}
```
Output for N = 10:
```text
Enter number of terms: Sn = 1.549768
```

(The sum tends to π²/6 = 1.6449 as N becomes large.)

## Check yourself

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

1. What term does the loop add?
   A. 1 / i
   B. i*i
   C. 1.0 / (i*i)
   D. 1.0 / i
   Answer: C. Series is 1/i^2. (Key point: Term)

2. Why use double and 1.0?
   A. To make the loop faster
   B. To avoid scanf
   C. To print integers
   D. To avoid integer division giving 0
   Answer: D. 1/(i*i) in ints would be 0 for i>1. (Key point: Integer division)

3. The sum tends to which value for large N?
   A. pi^2/6 = 1.6449
   B. 1
   C. 2
   D. infinity
   Answer: A. Basel series limit. (Key point: Limit)

## 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
- [Cosine series up to n terms](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acosine-series) — Computer Programming, chapter 5
- [Series sum 1/1¹+1/2²+… in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-series-sum-1-over-n) — Computer Programming, chapter 11
- [nth Fibonacci term prime check](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afibonacci-nth-prime) — Computer Programming, chapter 6
- [Series 1+11+111+… by recursion](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aseries-1-11-111-recursive) — Computer Programming, chapter 6
- [Series (2*3/5)+(4*5/7)+… with functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aseries-2x3-over-5-recursive) — Computer Programming, chapter 6

## 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
- [Series sum using Z-transform](https://www.bctengineer.com/question.md?key=semester_3%2Fmathematics_iii%3Aseries-sum-using-z-transform) — Mathematics III, chapter 3
- [Voltage build-up; series generator at no load](https://www.bctengineer.com/question.md?key=semester_4%2Felectrical_machines%3Avoltage-buildup-series-generator-no-load) — Electrical Machines, chapter 3
- [LandMeasure class and sum function](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Alandmeasure-class-sum) — Object Oriented Programming, chapter 4
