manip.cpp 586 B

1234567891011121314151617181920212223242526
  1. // manip.cpp -- using format manipulators
  2. #include <iostream>
  3. int main()
  4. {
  5. using namespace std;
  6. cout << "Enter an integer: ";
  7. int n;
  8. cin >> n;
  9. cout << "n n*n\n";
  10. cout << n << " " << n * n << " (decimal)\n";
  11. // set to hex mode
  12. cout << hex;
  13. cout << n << " ";
  14. cout << n * n << " (hexadecimal)\n";
  15. // set to octal mode
  16. cout << oct << n << " " << n * n << " (octal)\n";
  17. // alternative way to call a manipulator
  18. dec(cout);
  19. cout << n << " " << n * n << " (decimal)\n";
  20. // cin.get();
  21. // cin.get();
  22. return 0;
  23. }