Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- int k = 0;
- double x, e, d, s;
- printf("x = ");
- scanf("%lf", &x);
- printf("e = ");
- scanf("%lf", &e);
- printf("cos^2(%e) = ", x);
- while (31.416 < x) {
- x = x - 31.416;
- }
- while (x < -31.416) {
- x = x + 31.416;
- }
- s = 1;
- d = 1;
- while (e < fabs(d)) {
- k = k + 1;
- d = (-d) * x * x / ((2 * k - 1) * (2 * k));
- s = s + d;
- }
- printf("%e\n", s*s);
- printf("%3.3e",(pow(cos(x), 2)));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment