Answer to Question #56472 in C++ for Nithya

Question #56472
1)Write a program that asks the user to enter a number in decimal then displays it in binary and hexadecimal.
2)Write a program that reads a string that represents a number in hexadecimal then displays the equivalent number in decimal.
1
Expert's answer
2015-11-20T03:54:57-0500
#include <iostream>
#include <iomanip>
#include <bitset>
using namespace std;

int main() {
int number;
cin>>number;
bitset<32> x(number);
cout<<x<<endl;
cout<<setbase(16)<<number<<endl;

return 0;
}

--- Second programm ---
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
int number;
cin>>setbase(16)>>number;
cout<<setbase(10)<<number;

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS