Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double sum (int k, double x)
- {
- int i, j;
- double s, o, h;
- s = 0;
- j = -1;
- o = x;
- for (i=1; i<=k;i++)
- {h= (j*o) / i;
- s += (j*o) / i;
- j = -j;
- o *= x;
- }
- return(s);
- }
- int main(void)
- {
- int n;
- double h, res;
- scanf_s("%d", &n);
- scanf_s("%lf", &h);
- res = sum(n, h);
- printf("%f", res);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement