cout: change formats : cout scientific « Console « C++






cout: change formats

cout: change formats

#include <iostream>
using namespace std;

int main()
{
  // change formats
  cout.unsetf(ios::dec);
  cout.setf(ios::hex | ios::scientific);
  cout << 123.23 << " hello " << 100 << '\n';

  cout.setf(ios::showpos);
  cout << 10 << ' ' << -10 << '\n';

  cout. setf(ios::showpoint | ios::fixed);
  cout << 100.0;

  return 0;
}

           
       








Related examples in the same category

1.Sets both the uppercase and scientific flags and clears the uppercase flag
2.cout: number base, justification, and format flagscout: number base, justification, and format flags
3.Displays the value 100 with the showpos and showpoint flags turned on