76 289
Assignments Done
Successfully Done
In May 2019

Answer to Question #25914 in C++ for Mc Gyver

Question #25914
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?
Expert's answer
#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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions