hexa_to_binary

February 22, 2019
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;
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:

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
Powered by Blogger.