How to calculate square root in C#

3 Answers

0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		int a = 25;
        Console.WriteLine(Math.Sqrt(a));
  
        int b = 81;
        Console.WriteLine(Math.Pow(b, 0.5));
        
        int c = 85;
        Console.WriteLine(Math.Sqrt(c));
	}
}



/*
run:

5
9
9.21954445729289
     
*/


answered Apr 8, 2014 by avibootz
edited May 20, 2024 by avibootz
0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		double value = 121.0;
 
        Console.WriteLine("The square root of {0:F2} is {1:F2}", value, Math.Sqrt(value));
	}
}



/*
run:

The square root of 121.00 is 11.00
     
*/

 



answered May 20, 2024 by avibootz
0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		double value = 121.0;
 
        Console.WriteLine("The square root of {0:F2} is {1:F2}",value,Math.Pow(value, 0.5));
	}
}



/*
run:

The square root of 121.00 is 11.00
     
*/

 



answered May 20, 2024 by avibootz

Related questions

1 answer 152 views
152 views asked May 7, 2019 by avibootz
1 answer 96 views
96 views asked Jan 12, 2025 by avibootz
1 answer 84 views
84 views asked Jan 12, 2025 by avibootz
1 answer 67 views
67 views asked Jan 12, 2025 by avibootz
1 answer 89 views
89 views asked Oct 4, 2024 by avibootz
...