// Program by Akash Tripathi (@proakash256)
#include <stdio.h>
unsigned long long factorial(int n)
{
unsigned long long f = 1;;
for(int i = n; i >= 2; i = i - 1)
f = f * i;
return f;
}
int main()
{
int n;
float s = 0;
printf("Enter the number of terms upto which you want
to print the series : ");
scanf("%d" , &n);
for(int i = 1 , b = 1; i <= n; i = i + 1 , b = b + 2)
{
unsigned long long f = factorial(b);
if(i % 2 == 0)
s = s - ((float)i / f);
else
s = s + (i / (float)f);
}
printf("\nThe Sum of the series upto %d terms is %0.2f" , n , s);
return 0;
}
Comments
Post a Comment