hexa_to_binary
hexa_to_binary
// Hexa to binary.cpp : Defines the
entry point for the console application.
2
3
#include "iostream"
4
using namespace std;
5
int main()
6
{
7
long int n=0,a=1,deci=0,rem=0,bin=0,b=1;
8
cout<<"Enter the hexa number:";
9
cin >> n;
10
while(n!=0)
11
{
12
rem=n%10;
13
deci=deci+rem*a;
14
n=n/10;
n=n/10;
15
a*=16;
16
}
17
cout<<deci<<endl;
18
n=deci;
19
while(n!=0)
20
{
21
rem=n%2;
22
bin=bin+rem*b;
23
n/=2;
24
b*=10;
25
}
26
cout<<bin<<"\n";
27
return 0;
28
}
No comments: