fork(1) download
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. // Find the sqr root of the number
  5. cout<<"Enter the number\n";
  6. int num;
  7. cin>>num;
  8.  
  9. int start=0;
  10. int sqrts;
  11. while(start<num){
  12.  
  13. int mid=start+(num-start)/2;
  14. if(mid*mid>=num){
  15. sqrts=mid;
  16. start=mid+1;
  17. }else{
  18. num=mid-1;
  19. }
  20.  
  21. }
  22.  
  23. cout<<sqrts;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5288KB
stdin
80
stdout
Enter the number
79