Set showpos flag for decimal : int output « Data Type « C++






Set showpos flag for decimal

  
#include <iostream>

using namespace std;

int main()
{
  int x = 100;
  double f = 98.6;
  double f2 = 123456.0;
  double f3 = 1234567.0;

  // Set the showpos flag.
  cout.setf(ios::showpos);
  cout << "Setting showpos flag.\n";
  cout << "x in decimal after setting showpos: " << x << endl;

  return 0;
}
  
    
  








Related examples in the same category

1.Decimal in hexadecimal
2.Decimal in octal
3.Decimal in decimal
4.Display decimal value as hexadecimal value
5.Display decimal value as Octal value
6.Output integer with different base: 8, 10, 16
7.Right justification
8.Left justification
9.Use .(dot) as place holder
10.Set width of output
11.Using hex, oct, dec and setbase stream manipulators.
12.Printing an integer with internal spacing and forcing the plus sign.
13.Making I/O in Octal Format