Question
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?
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?
Answers
GPT 3.5
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.
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.
Related Questions
sqrt 6 * sqrt 8
also
sqrt 7 * sqrt 5
6.92820323 and 5.916079783
So you can see the steps...
tan60=2 tan30/1-tan^2 30
sqrt(3)=I'm confused of that 2 but i guess it means to multiply.
again....
Evaluate sqrt7x (sqrt x-7 sqrt7) Show your work.
sqrt(7)*sqrt(x)-sqrt(7)*7*sqrt(7)
sqrt(7*x)...
Select all the expressions that represent a rational number. sqrt(169) + 7; 3 - sqrt(8); (sqrt(27))/...