Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- #define elsp 0.005
- void calculation(double lg,double x)
- {
- double ng=0;
- ng=0.5*(lg+x/lg);
- if(fabs(ng-lg)>=elsp){
- calculation(ng,x);
- }
- else printf("ans : %.2lf",ng);
- }
- int main()
- {
- double x,lg=1.0;
- printf("please input a number : ");
- scanf("%lf",&x);
- calculation(lg,x);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement