#include <conio.h>
#include <math.h>
#include <stdio.h>
int main (void){
clrscr();
int dec=0, flag = 0.0;
int bin, bit;
double exp = 0.0;
printf("Program konversi biner ke desimal\n");
printf("---------------------------------\n");
printf("---------Nick_Alexander----------\n\n");
printf("Masukan Binary : ");
scanf("%d",&bin);
while(bin){
bit = bin%10;
if (bit != 0 && bit != 1){
flag = 1 ;}
bin = bin/10;
dec = dec+bit*pow(2,exp);
exp++ ;}
if (flag){ printf("\nBukan Biner\n");}
else { printf("\nDesimal : %d\n",dec);}
getch();
return 0;
}
Demikianlah Program konversi bilangan Biner ke desimal memakai C++.