Advertisement
Guest User

xd

a guest
Oct 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int p, L=20, i;
  7.  
  8. float E=0.001, a;
  9.  
  10. main(){
  11. cout<<"Podaj liczbe z ktorej chcesz wyciagnac pierwiastek kwadratowy: ";
  12. cin>>p;
  13. a=p;
  14. for(i=0;abs(a-p/a)>E&&i<L;i++) a=(a+p/a)/2;
  15. cout<<"\n"<<a;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement