Problem statement
Write a c program to calculate square root of any number using Babylonian method
Write a c program to calculate square root of any number using Babylonian method
#include<stdio.h>
int main()
{
double x,y,p;
printf("enter x \n");
scanf("%lf",&x);
y=x;
do
{
p=y;
y=((y+(x/y))/2);
}
while((p-y)>.00001);
printf("the sq. root is %lf \n",y);
return 0;
}
No comments:
Post a Comment