#include<stdio.h>
float SquareRoot(float num);
void main()
{
float input, ans;
void main()
{
float input, ans;
ans = SquareRoot(9);
printf("\n Square Root : %f", ans);
}
float SquareRoot(float num)
{
if(num >= 0)
{
float x = num;
int i;
for(i = 0; i < 20; i ++)
{
x = (((x * x) + num) / (2 * x));
}
return x;
}
}
No comments:
Post a Comment