fork(4) download
  1. //Finding square root of a number
  2. #include<stdio.h>
  3. int main()
  4. {
  5. int N;
  6. printf("Enter the number");
  7. scanf("%d",&N);
  8. float low=0;float high=N;
  9. float mid;
  10.  
  11. while(high-low>0.0002)
  12. {
  13. mid=(low+high)/2;
  14. if( (mid*mid) <N)
  15. low=mid;
  16.  
  17. if( (mid*mid)==high)
  18. {printf("Answer is %f",mid);return 0;}
  19.  
  20. if( (mid*mid) >N)
  21. high=mid;
  22. }
  23. printf("%f",mid);
  24. return 0;
  25. }
Success #stdin #stdout 0s 2900KB
stdin
Standard input is empty
stdout
Enter  the  numbernan