Program to calculate Square root of X manually.

#include<stdio.h>
float sqroot(float n)
{ int x=0;
float guess=10.0,quot,avg;
while(x!=20)
{
quot=n/guess;
guess=(guess+quot)/2;
x++;
}
return guess;
}
main()
{ float n;
printf("\nEnter the number to calculate Square root of it!!");
scanf("%f",&n);
printf("\nSquare root of n is=%f",sqroot(n));
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s