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;
Comments
Leave a comment