Demonstrate an I/O manipulator: setprecision(2) and setw(20) : cout setw setprecision « Console « C++






Demonstrate an I/O manipulator: setprecision(2) and setw(20)

Demonstrate an I/O manipulator: setprecision(2) and setw(20)


 
#include <iostream> 
#include <iomanip> 
using namespace std; 
 
int main() 
{ 
  cout << setprecision(2) << 1000.243 << endl; 
  cout << setw(20) << "Hello there."; 
 
  return 0; 
}

           
       








Related examples in the same category

1.Cout: precision 4Cout: precision 4
2.Uses I/O manipulators to display the table of squares and square roots.
3.Enters a character and outputs its octal, decimal, and hexadecimal code.