60 465
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #56420 in C++ for raneem

Question #56420
Write a program that asks the user to enter a number in decimal then displays it in binary
and hexadecimal.
Expert's answer
#include <iostream>

using namespace std;
void hexaD(int a, char b);
int main(){

int number;
cout<<"Please enter Number : ";
cin>>number;
int bankint[20];
int totalint=-1;
for(int q=0;number>0;q++){
if((number%2) == 0)
bankint[q]=0;
else
bankint[q]=1;
totalint++;
number/=2;
}
cout<<"Number binary = ";
for(int j=totalint;j>=0;j--) /* reversved */
cout<<bankint[j];


}

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