Square Root calculation in C#.net

Naraayanan
Posted by Naraayanan under C# category on | Points: 40 | Views : 6026
Create a Function for Square Root:

Member Declaration:
 public static string strvalue;
public static string res;
Function/Method
     #region Square Root 
public static string squareRoot(double fv, double sv)
{
double Result;

for (int idx = 1; idx < sv+1; idx++)
{
if (idx == 1)
{
Result = Math.Pow(fv, idx);
res = Convert.ToString(Result);
}
else if (idx > 1)
{
Result = Math.Pow(fv, idx);
res = res + "," + Convert.ToString(Result);
}
}
strvalue =res;
return strvalue;
}
#endregion Square Root


Call the Method in your Application like this
string str = squareRoot(2, 10);
MessageBox.Show(str);

Output in the MessageBox :

2,4,8,16,32,64,128,256,512,1024

Comments or Responses

Login to post response