How to calculate PI value with acos() function in C++

2 Answers

0 votes
#include <iostream>
#include <cmath>

int main()
{
    double pi = acos(-1);
 
    std::cout << "pi = " << pi << "\n";
}

 
/*
run:
 
pi = 3.14159
 
*/

 



answered Mar 30, 2016 by avibootz
edited Oct 4, 2024 by avibootz
0 votes
#include <iostream>
#include <cmath>

int main()
{
    double pi = 2 * acos(0.0); 
 
    std::cout << "pi = " << pi << "\n";
}

 
/*
run:
 
pi = 3.14159
 
*/

 



answered Oct 4, 2024 by avibootz

Related questions

2 answers 295 views
2 answers 113 views
2 answers 114 views
2 answers 132 views
2 answers 129 views
2 answers 123 views
1 answer 131 views
...