Problem statement
Write a c program to calculate the value of pi*pi/6 using Basel's equation
the equation is pi2/6=1/12+1/22+1/32 and so on
#include<stdio.h>float pi( float i);
int main()
{
float y,i;
i=1.0;
y=pi(i);
printf("the value of pi*pi/6 is %f",y);
return 0;
}
float pi(float i)
{
float e,sum;
e=1/(i*i);
if(e<.000001)
{
return 0;
}
else
{
i++;
sum=e+pi(i);
}
return sum;
}
No comments:
Post a Comment