do..while循环问题
#include<stdio.h>#include<math.h>
void main()
{
float a;
float x1=a/2,x2;
printf("a=");
scanf("%f",&a);
do
{
x2=(x1+a/x1)/2;
x1=x2;
}while(fabs(x1-x2)>=1e-5);
printf("the root of %5.2f is %8.5f",a,x2);
作用是求a的平方根。但得不到正确结果,难道X2也要在do..while循环外赋值吗?