C# : Program to calculate square root of any number

In this C# tutorial we "calculate square root of any number entered by the user" . For this here we are taking two variables "sq" for square root and "n" for number entered by the user respectively. Also here we are using "Math.Sqrt" method which is used to find square root of a number at runtime.  Now, lets get started!!

>using System;
​class prg
{
 public static void Main(String []args)
 {
        double sq,n;
        Console.WriteLine("Enter any number : ");
        n=Convert.ToInt32(Console.ReadLine());
        //Math.Sqrt method computes a square root value at runtime. 
        sq=Math.Sqrt(n);
      Console.WriteLine("Square root of  " + n +  "is"  + sq);
}
}
SHARE

Raunak Hajela

Hi. I’m CEO/Founder of Kodestat. I’m Student, Geek, Web Designer, Developer, Blog Enthusiast and Player. Inspired to make things looks better. I like playing with codes plus I am marvel fan :-P You can check my design portfolio here. For consulation fell free to drop an email at raunakhajela@gmail.com.

  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment