Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- main(){
- float x, a, sum, eps=1e-4;
- int i=1, lim=1000;
- do {
- printf("Input x [-1; 1]: ");
- scanf("%f", &x );
- } while(x > 1 || x < -1);
- a = sum = 1;
- for (i; fabs(a) >= eps ; i++){
- a*= x*x/(2*i)/(2*i-1);
- sum+=a;
- if (i > lim) {
- printf("divergents");
- break;
- }
- }
- if (i <= lim)
- printf("ch(%.1f): %f\ntest:\t %f" , x, sum, cosh(x));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement