1 + 1/4 + 1/9 + 1/16 + ..............+ 1/n²

//1 + 1/4 + 1/9 + 1/16 + ..............+ 1/n²
Program:

#include<stdio.h>
int main()
{
int n,i;
float sum=0;
printf("Enter n: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+1.0/(i*i);
}
printf("sum= %f",sum);
return 0;
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...