Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int p, L=20, i;
- float E=0.001, a;
- main(){
- cout<<"Podaj liczbe z ktorej chcesz wyciagnac pierwiastek kwadratowy: ";
- cin>>p;
- a=p;
- for(i=0;abs(a-p/a)>E&&i<L;i++) a=(a+p/a)/2;
- cout<<"\n"<<a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement