How to output the number pi in C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to output the number pi in C++?

14th Dec 2017, 2:20 PM
Alisher
3 Answers
+ 8
Approximation without any methods etc.. cout << 22.0 / 7;
14th Dec 2017, 2:57 PM
Cool Codin
Cool Codin - avatar
+ 4
#define _USE_MATH_DEFINES #include <math.h> int main() { cout << M_PI; ...
14th Dec 2017, 3:56 PM
Kirk Schafer
Kirk Schafer - avatar
+ 3
#include <iostream> #include <cmath> using namespace std; int main() { cout << atan(1)*4; return 0; }
14th Dec 2017, 2:35 PM
Augustinas Lukauskas
Augustinas Lukauskas - avatar