Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started