Source code Desimal to Biner Turbo C

# include <stdio.h>

# include <math.h>

# include <conio.h>

int main (void) {int dec = 0, flag = 0.0;

int bin, bit;

double exp = 0.0;

printf(“Masukkan Bilangan 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 bilangan biner !!! \n”);

}

else {print (“\n +++ nilai dalam desimal : % d\n”,dec); }

getch();

return 0;

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: