1234567891011121314151617181920212223242526 |
- // manip.cpp -- using format manipulators
- #include <iostream>
- int main()
- {
- using namespace std;
- cout << "Enter an integer: ";
- int n;
- cin >> n;
- cout << "n n*n\n";
- cout << n << " " << n * n << " (decimal)\n";
- // set to hex mode
- cout << hex;
- cout << n << " ";
- cout << n * n << " (hexadecimal)\n";
- // set to octal mode
- cout << oct << n << " " << n * n << " (octal)\n";
- // alternative way to call a manipulator
- dec(cout);
- cout << n << " " << n * n << " (decimal)\n";
- // cin.get();
- // cin.get();
- return 0;
- }
|