C++ int type integer values Formatting

Description

C++ int type integer values Formatting

#include <iostream>
#include <cmath>                       // For square root function
using std::cout;//from   ww  w  .  jav a 2s .c  om

int main()
{
    int a{16}, b{66};
    cout << std::setw(5) << a << std::setw(5) << b << std::endl;
    cout << std::left << std::setw(5) << a << std::setw(5) << b << std::endl;
    cout << " a = " << std::setbase(16) << std::setw(6) << std::showbase << a
         << " b = " << std::setw(6) << b << std::endl;
    cout << std::setw(10) << a << std::setw(10) << b << std::endl;
}



PreviousNext

Related