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