This program Demonstrates the use of the Numeric manipulator
Source Code:
Result:
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <iostream.h> #include <conio.h> #include <iomanip> using namespace std; int main() { int d123 = 123; cout << "Value in decimal :\t"; cout << setw(5) << d123 << setw(5) << d123 << endl; cout << "Value in hexadecimal: \t" ; cout << hex; cout << setw(5) << d123 << setw(5) << d123 << endl; cout << "Value in octal: \t"; cout << oct; cout << setw(5) << d123 << setw(5) << d123 << endl; cout << "Value in decimal: \t"; cout << dec; cout << setw(5) << d123 << setw(5) << d123 << endl; getch (); //return 0; } //main |
Result:
Value in decimal : 123 123 Value in hexadecimal: 7b 7b Value in octal: 173 173 Value in decimal: 123 123
No comments:
Post a Comment