fork download
  1. #include <iostream>
  2. #include<stdlib.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int num,i=2;
  8. cout<<"Enter the number:";
  9. cin>>num;
  10. if(num==0||num==1)
  11. {
  12. cout<<"The sqaure root is :"<<num;
  13. exit(0);
  14. }
  15. while((num/i)>=i)
  16. {
  17. i++;
  18. }
  19. cout<<"The square root of "<<num<<" is:"<<i-1;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3472KB
stdin
16
stdout
Enter the number:The square root of 16 is:4