I'm new to C# and keep getting a divide by zero error with this function, I think its to do with how I'm passing my parameters but I'm not sure - any ideas?
double sqrRoot(int value, int sigFig)
{
int x=sigFig*100;
for (int i=0; i<sigFig; i++)
{
x=1/2*(x+(value/x));
}
return x;
}
//Example usage
Console.WriteLine(sqrRoot(125348,6));
(Returns the following error message in Solo Learn IDE)
Unhandled Exception: System.DivideByZeroException: Attempted to divide by zero. at SoloLearn.Program.g__sqrRoot0_0(Int32 value, Int32 sigFig) at SoloLearn.Program.Main(String[] args)