How to calculate PI value with atan() function in C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            double pi = Math.Atan(1) * 4;

            Console.WriteLine("pi = {0}", pi);
        }
    }
}


/*
run:

pi = 3.14159265358979

*/

 



answered Apr 1, 2016 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            float zero = 0;
            float Infinity = 1 / zero;
            double pi = 2 * Math.Atan(Infinity);

            Console.WriteLine("pi = {0}", pi);
        }
    }
}


/*
run:

pi = 3.14159265358979

*/

 



answered Apr 2, 2016 by avibootz

Related questions

2 answers 217 views
2 answers 271 views
2 answers 268 views
2 answers 262 views
2 answers 357 views
2 answers 483 views
2 answers 303 views
...