C Programming
Learn C from A to Z
Home
Basic Program
Interview Program
Fun coding
Creative program
Videos
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.
Facebook
Twitter
Google+
Pinterest
StumbleUpon
Delicious
LinkedIn
Reddit
Technorati
No comments:
Post a Comment
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment