Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
using namespace std; int main() { // Booleans cout << "Booleans\n"; cout << false << "\n"; cout.setf(ios::boolalpha); cout << false << "\n"; // Hexadecimal and octal numbers cout << "\nHexadecimal and octal numbers\n"; int myInt = 14; cout << myInt << "\n"; cout.setf(ios::hex, ios::basefield); cout << myInt << "\n"; cout.setf(ios::oct, ios::basefield); cout << myInt << "\n"; cout.setf(ios::showbase); cout.setf(ios::uppercase); cout.setf(ios::hex, ios::basefield); cout << myInt << "\n"; cout.setf(ios::oct, ios::basefield); cout << myInt << "\n"; cout.setf(ios::dec, ios::basefield); // Floating point numbers cout << "\nFloating point numbers\n"; float myFloat = 19.99; cout << myFloat << "\n"; cout.setf(ios::fixed, ios::floatfield); cout << myFloat << "\n"; cout.setf(ios::scientific, ios::floatfield); cout << myFloat << "\n"; cout.unsetf(ios::floatfield); cout.setf(ios::showpos); cout.setf(ios::showpoint); cout << 12345.0 << "\n"; // Alignment cout << "\nAlignment\n"; cout.setf(ios::left, ios::adjustfield); cout << setw(10) << "Left" << "\n"; cout.setf(ios::right, ios::adjustfield); cout << setw(10) << "Right" << "\n"; cout.setf(ios::internal, ios::adjustfield); cout << setw(10) << 12345.0 << " (Internal)\n"; return 0; }
Booleans
0
false
Hexadecimal and octal numbers
14
e
16
0XE
016
Floating point numbers
19.99
19.990000
1.999000E+01
+12345.0
Alignment
Left
Right
+ 12345.0 (Internal)