平方根関数に引数を入力しようとしています。この関数は、b に b を掛けた値を受け入れますが、b に b を掛けて 4 を引いた値は受け入れません。なぜでしょうか? どうすればこれを回避できますか?前もって感謝します。
#include <stdio.h>
//Function to compute square root of a number
float squareRoot (float x)
{
float guess = 1.0;
while (( x/ (guess * guess)) != 1)
{
guess = (x/ guess + guess) / 2.0;
}
return guess;
}
int main (void)
{
float b;
float valueOne;
float answerOne;
float squareRoot (float x);
printf("give me a 'b'\n");
scanf("%f", &b);
valueOne = b*b-4;
answerOne = squareRoot(valueOne);
printf("%f", answerOne);
return 0;
}