Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main() {
- float EPS = 0;
- float EP = 1, ep = 1;
- float x = 0;
- printf("Enter EPS(0 < EPS < 1) = ");
- if(scanf("%f", &EPS) != 1)
- {
- printf("Error.\n");
- return 0;
- }
- printf("Enter x = ");
- if(scanf("%f", &x) != 1)
- {
- printf("Error.\n");
- return 0;
- }
- long double y = 1;
- float powx = x*x;
- int factorial = 2;
- int f = 2;
- if(EPS >= 1 || EPS <= 0)
- {
- printf("Error EPS.\n");
- return 0;
- }
- printf("cos(x) = %f;\n", cos(x));
- while(ep >= EPS)
- {
- EP = powx/(factorial)*(-1);
- ep = powx/factorial;
- y = y + EP;
- powx = powx*x*x;
- factorial = factorial*(f + 1)*(f + 2);
- f = f + 2;
- }
- printf("Teilor = %lf\n", y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement