Tuesday, July 2, 2013

Write a program to find square root of the given ni without using sqrt function ?

Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
const float x=0.00001;
float g=1.0,no;
clrscr();
printf("\n enter the number");
scanf("%f",&no);
do
{
g=(no/g+g)/2.0;
}
while(abs(g*g-no)>=.00001);
printf("\n the square root of %.0f is %.4f",no,g);
getch();
}



Output:

 



Like the Post? Do share with your Friends.

No comments:

Post a Comment