-
Description Takes the square root of an int and returns a double.
Code double sqrt (int a,int accuracy=20) { double out = a; for(int i=0;i<accuracy;i++) { out = (out+a/out)/2; } return out; }
Test Cases // TODO: Replace examples and use TDD development by writing your own tests Describe(square_root) { It(should_take_square_root) { Assert::That(sqrt(4), Equals(2)); Assert::That(sqrt(16), Equals(4)); Assert::That(sqrt(169), Equals(13)); } };
Output:
-
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}