Question: #include / / Function to find square root of given number up to given precision float squareRoot ( int number, int precision ) { int
#include
Function to find square root of given number up to given precision
float squareRootint number, int precision
int start end number;
int mid;
variable to store the answer
float ans;
for computing integral part of square root of number
while start end
mid start end;
if mid mid number
ans mid;
break;
incrementing start if integral part lies on right side of the mid
if mid mid number
start mid ;
ans mid;
decrementing end if integral part lies on the left side of the mid
else
end mid ;
For computing the fractional part of square root up to given precision
float increment ;
for int i ; i precision; i
while ans ans number
ans increment;
loop terminates when ans ans number
ans ans increment;
increment increment ;
return ans;
Driver code
int main
Function calling
printff
squareRoot;
Function calling
printff
squareRoot;
return ;
please explain this C code and also manual trace it
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
