This C Program calculates the Sum of Series 1^2 + 2^2 + …. + n^2. Then the Sum of the series 1^2 + 2^2 + …. + n^2 = n(n + 1)(2n + 1) / 6.

Here is source code of the C Program to Find the Sum of Series 1^2 + 2^2 + …. + n^2. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C Program to find the sum of series 1^2 + 2^2 + …. + n^2.`

`*/`

`#include <stdio.h>`

int main()

`{`

int number, i;

int sum = 0;

printf("Enter maximum values of series number: ");

scanf("%d", &number);

sum = (number * (number + 1) * (2 * number + 1 )) / 6;

printf("Sum of the above given series : ");

for (i = 1; i <= number; i++)

`{`

if (i != number)

printf("%d^2 + ", i);

`else`

printf("%d^2 = %d ", i, sum);

`}`

return 0;

`}`

Output: $ cc pgm18.c $ a.out Enter maximum values of series number: 4 Sum of the above given series : 1^2 + 2^2 + 3^2 + 4^2 = 30

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.