dec 2 hex 2 oct 2 bin

itprofessionalsrocks.blogspot.com
//decimal to hexadecimal conversion,octal conversion,binary conversion
//dec 2 hex 2 oct 2 bin CONVERSION//
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,d,t,p,k=1,i=1,j=1;
int bin=0,bin1=0,bin2=0,bin3=0,rev=0;
cout<<"enter the number";
cin>>a;
cout<<"enter the number for its conversion to binary";
cin>>t;
p=a;
while(a>0)
{
d=a%8;
bin=bin+i*d;
a=a/8;
i=i*10;
}
while(t>0)
{
d=t%2;
bin1=bin1+j*d;
t=t/2;
j=j*10;
}

while(p>0)
{
d=p%16;
bin2=bin2+k*d;
p=p/16;
k=k*10;
}
cout<<"binary\n"<<bin1;
cout<<"octal\n" <<bin;
cout<<"hexadecimal\n"<<bin2;

getch();
}

Comments

Popular posts from this blog

REFLECTION OF A TRIANGLE (COMPUTER GRAPHICS)