Set width of output : int output « Data Type « C++






Set width of output

  
#include <iostream>
using namespace std; 
int main(void){
   int i;

   for (i = 0; i < 3; i++){
     cout.width(5);
     cout << i << '\n';
    }
}
  
    
  








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.Using hex, oct, dec and setbase stream manipulators.
11.Printing an integer with internal spacing and forcing the plus sign.
12.Set showpos flag for decimal
13.Making I/O in Octal Format