Answer to Question #25914 in C++ for Mc Gyver
2013-03-06T21:38:47-05:00
conversation of all number system in one c++ program. it is possible? i mean convert the binary to decimal, octal to hexa and soon. is possible in a one program?
1
2013-03-12T11:57:58-0400
#include <iostream> #include <cstdlib> #include <string> using namespace std; int main() { int ns_from, ns_to; char buffer[64]; string tmp; int number; cout << "Enter the number system to convert from (2..36): "; cin >> ns_from; cout << "Enter the number to convert: "; cin >> tmp; cout << "Enter the number system to covert to: "; cin >> ns_to; cout << endl; number = strtol(tmp.c_str(), NULL, ns_from); _itoa(number, buffer, ns_to); cout << "The number converted: " << buffer << endl; return 0; }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments
Leave a comment