67 172
Assignments Done
99,3%
Successfully Done
In November 2018

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.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions