Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double SqrtNumber(double num)
- {
- double lower_bound=0;
- double upper_bound=num;
- double temp=0; /* ek edited this line */
- int nCount = 50;
- while(nCount != 0)
- {
- temp=(lower_bound+upper_bound)/2;
- if(temp*temp==num)
- {
- return temp;
- }
- else if(temp*temp > num)
- {
- upper_bound = temp;
- }
- else
- {
- lower_bound = temp;
- }
- nCount--;
- }
- return temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement