Header Ads Widget

Responsive Advertisement

Square Root Function without using Library Function

 


#include<stdio.h>

float squareRoot ( float n);

int main()
{ float n;
printf("Enter Number : ");
scanf("%f",&n);
printf("The Root of Number %f is = %f",n,squareRoot(n));
return 0;
}

float squareRoot(float n){
if(n==0){ return 0;}
float sqrt, temp=0.00;
sqrt=n/2;
while(sqrt!=temp){
temp = sqrt;
sqrt = (n/temp + temp)/2;
}

return sqrt ;

}
   


Post a Comment

0 Comments