Sunday, May 24, 2009

Finding a Square Root

/* Custom Project and Libraries Copyright, 2006. Venkat, ISS */

using System;
using System.Collections.Generic;
using System.Text;
using ISS.RV.LIB;

namespace Method
{
class exercise42
{
static void Main()
{
double number = ISSConsole.ReadInt("Enter the number");
//Console.WriteLine("The Square root Number is:" + NumberType(number));
Console.WriteLine(" Square root of {0} is {1}", number, NumberType(number));


#region /* Do not remove this or write codes after this */
ISSConsole.Pause();
#endregion
}
static double NumberType(double num)
{

double G = ISSMath.RND() * num;

while (Math.Abs(G * G - num) > 0.0000001)
{
G = (G + num/ G) / 2;

//Console.WriteLine("{0:0.0000000}", G * G - num);
}

// Console.WriteLine(" Square root of {0} is {1}", num, G);
return G;

}
}
}

No comments:

Post a Comment