How to circle numbers

I´m working on a problem and part of the problem is to find the average of an array and i find it but it comes out with a lot of decimals. So how can I circle it to two decimals ?
You can use the setprecision function that's found in <iomanip>
http://cplusplus.com/reference/iostream/manipulators/setprecision/

1
2
3
4
5
6
7
8
9
#include <iostream>
#include <iomanip>

int main()
{
  double pi = 3.141592653589793238462643383279502884197169399375105820974944;
  std::cout << std::fixed << std::setprecision(2) << pi;
  return 0;
}
3.14
Last edited on
do you know those 60 decimals of pi by heart or did you just copy it ? ;d
He has calculated the pi just now.
How do you get the output next to the code?
Topic archived. No new replies allowed.