int sqrt(int number);

sq_root = sqrt(1000);

int sqrt(int number)

int guess=5, i=1;
for(i=1;guess=5;i != guess;)
{
i = guess;
guess = (i + (10000/i))/2;
}
return guess;
}

what does each line do?

1 answer

int sqrt(int number); - This line is a function declaration for a function named sqrt, which takes an integer parameter named number and returns an integer value.

sq_root = sqrt(1000); - This line assigns the result of calling the sqrt function with the value 1000 to a variable named sq_root.

int sqrt(int number) - This line starts the definition of the sqrt function. It specifies that the function takes an integer parameter named number and returns an integer value.

int guess=5, i=1; - This line declares and initializes two integer variables named guess and i, with initial values 5 and 1 respectively.

for(i=1; guess=5; i != guess;) - This line starts a for loop with i set to 1, guess set to 5, and the condition i != guess. This creates an infinite loop because the condition is never false.

i = guess; - This line sets the value of i to the current value of guess.

guess = (i + (10000/i))/2; - This line updates the value of guess using the Babylonian method to approximate the square root of 10000.

return guess; - This line ends the sqrt function and returns the value of guess as the result of the function.
Similar Questions
  1. tan60=2 tan30/1-tan^2 30sqrt(3)=I'm confused of that 2 but i guess it means to multiply. again.. sqrt(3)= (2) sqrt(3)/3 / 1-
    1. answers icon 1 answer
    1. answers icon 3 answers
  2. Evaluate sqrt7x (sqrt x-7 sqrt7) Show your work.sqrt(7)*sqrt(x)-sqrt(7)*7*sqrt(7) sqrt(7*x)-7*sqrt(7*7) sqrt(7x)-7*sqrt(7^2)
    1. answers icon 1 answer
  3. sqrt 6 * sqrt 8also sqrt 7 * sqrt 5 6.92820323 and 5.916079783 So you can see the steps — sqrt 6 * sqrt 8 = sqrt 48 sqrt 7 *
    1. answers icon 0 answers
more similar questions