1. numbers with decimals

im using the double command for an array that has decimals in it, but when it prints out at the end there is too many numbers after the decimal.

so i was wanting to know if there is a way to make it so it only prints out up to 2 decimal places.

thanks.

2. Try this.
Code:
```   #include <iostream>
#include <iomanip>
using namespace std;
.
.
.
double num = 40.3527;
cout << "num:" << setprecision(2) << num << endl;```

3. how do you restrict the thing to calculate and round it to two decimal places ?

4. how do you restrict the thing to calculate and round it to two decimal places ?
You need to use the 'fixed' manipulator in conjunction with setprecision(). Without it, the setprecision() argument will determine the number of significant places that are displayed, not the number of decimal places.
Code:
```#include <iomanip> // for 'fixed'
#include <cstdlib> // system call
#include <iostream>
using namespace std;

int main(void)
{
const double num = 123.45678;
cout << "'fixed' flag not set:  " << setprecision(4) << num << endl;
cout << "'fixed' flag set:      " << fixed << setprecision(4) << num << endl;
double num2 = num * 10;
cout.unsetf(ios::fixed);    // unsets the 'fixed' flag
cout << "'fixed' flag not set:  " << setprecision(2) << num2 << endl;
cout << "'fixed' flag set:      " << fixed << setprecision(2) << num2 << endl << endl;
system("PAUSE");
return 0;
}```
If you run this code, you'll see a rather significant difference when 'num2' is calculated and displayed.

-Skipper