Answer to Question #61887 in C++ for James Kulesa
2016-09-09T00:29:28-04:00
I have assignment where I need to prompt user for an integer to convert to binary, oct, hex.
The prompt is suppose to be enter Integer to convert or DONE to stop. how do you do this being that the integer and "DONE" are of different types.
1
2016-09-12T06:43:03-0400
#include <iostream> #include <cstdio> #include <stdlib.h> #include <string.h> using namespace std; int main() { char answer[10]; cout << "Enter Integer to convert or DONE to stop:" << endl; cin>>answer; if (strcmp(answer, "DONE")!=0){ int number; number=atoi(answer); cout<<"\nOct:"<<oct<<number<<"\nHex:"<<hex<<number; char binary[80]; itoa(number, binary, 2); cout<<"\nBinary:"<<binary; } cout<<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