Kamis, 14 Oktober 2010

konveksi biner ke desimal



Listing Program

#include
#include
#include
int main(void) {
int dec = 0, flag=0.0;
int bin, bit;
double exp = 0.0;
printf("program konveksi biner ke desimal\n");
printf("---------------------------------\n");
printf("_____________selly______________\n\n");
printf("Masukkan 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("\n bukan biner\n");
}
else { printf("\n Desimal : %d\n", dec);
}
getch();
return 0;
}

Tidak ada komentar:

Posting Komentar