#include"stdio.h"
#include"iostream.h"
#include"conio.h";
void b2d()
{
char b[8];
int d=0,i=0;
printf("\nbinary= ");
scanf("%s",&b);
while(b[i]!=0)
{ if(b[i]=='0'||b[i]=='1')
{
d=d*2+b[i]-48;
}i++;
}
printf("\ndesimal = ");
printf("%d\n",d);
}
void d2b()
{
int d,b,i,k=128;
printf("\ndesimal = ");
scanf("%d",&d);
printf("binary = ");
for(i=0;i<8;i++)
{
b=d/k;
printf("%d",b);
d=d%k;
k=k/2;
}puts("");
}
main()
{char pil;
printf(" \t==program konversi==\n\n");
puts("\n\n------MENU------");
puts("a. konversi biner to desimal ");
puts("b. konversi desima to biner \n");
cout<<"masukan pilihan anda => ";
cin>>pil;
if(pil=='a')
b2d();
if(pil=='b'||pil=='B')
d2b();
}