Home » Sum of series in C language 1 + 1/(2*2) + 1/(3*3) + 1/(4*4) + ….. + 1/(n*n) using pow() Function

# Sum of series in C language 1 + 1/(2*2) + 1/(3*3) + 1/(4*4) + ….. + 1/(n*n) using pow() Function

Learn about Sum of series in C language 1 + 1/(2*2) + 1/(3*3) + 1/(4*4) + ….. + 1/(n*n) using pow() Function in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Contents

#### Sum of series in C language 1 + 1/(2*2) + 1/(3*3) + 1/(4*4) + ….. + 1/(n*n) using pow() Function

The below program finds the value of the given series,

1 + 1/(2*2) + 1/(3*3) + 1/(4*4) + ….. + 1/(n*n)

Program:

``````#include<stdio.h>
#include<math.h>
int main()
{
int n, i=1;
float sum=0.0;

printf("Enter the limit (n Value): ");
scanf("%d",&n);

while(i<=n)
{
sum+=(1.0/pow(i,2)); //sum = sum + 1.0/ pow(i,2)
i++;
}

printf("Sum = %f", sum);

return 0;
}``````

Output:

Enter the limit (n Value): 5
Sum = 1.463611

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.