Skip to content

Instantly share code, notes, and snippets.

@MinhasKamal
Last active December 7, 2015 15:40
Show Gist options
  • Save MinhasKamal/fc6fdee1c661cc8d1c4b to your computer and use it in GitHub Desktop.
Save MinhasKamal/fc6fdee1c661cc8d1c4b to your computer and use it in GitHub Desktop.
/**
* Name: Minhas Kamal
* Date: 02-Apr-2013
**/
#include <stdio.h>
float sqrt(int i);
int main()
{
int x;
printf("Enter your integer: ");
scanf("%d", &x);
printf("%f", sqrt(x));
return 0;
}
float sqrt(int i)
{
float x=1.0;
float y;
for( ; y-x>0.0001 || x-y>0.0001; ++x)
{
y=(x+i/x)/2;
}
return y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment