Advertisement
Guest User

ow to output with 3 digits after the decimal point with C++

a guest
Apr 10th, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. //How to output with 3 digits after the decimal point with C++ stream?
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main () {
  7.     double f = 113.;
  8.     cout.setf(ios::fixed,ios::floatfield);
  9.     cout.precision(3);
  10.     cout << f << endl;
  11.     return 0;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement