Program Konversi Bilangan Desimal Ke Biner Di Pascal
Program Konversi_Decimal_to_Biner;
uses crt;
var
bil : integer;
function decToBin (desimal : integer):string;
var hasilbagi, sisa : integer;
bin : char;
bilBiner : string;
begin
hasilbagi :=desimal div 2;
bilBiner :='';
while (hasilbagi >= 1) do
begin
sisa := desimal mod 2;
if (sisa=0) then bin :='0'
else if (sisa = 1) then bin :='1';
bilBiner:=bin+bilBiner;
desimal:=hasilbagi;
hasilbagi:=desimal div 2;
end;
decToBin:='1'+bilBiner;
end;
begin
textbackground(1);
clrscr;
textcolor(4);
writeln(' ____----____----____----____----____ ');
writeln(' | | ');
writeln(' | KONVERSI BILANGAN DESIMAL KE BINER | ');
writeln(' |------------------------------------| ');
writeln(' | | ');
textcolor(5);
writeln(' | Oleh : Rhosy | ');
textcolor(4);
writeln(' |___________ --------------__________| ');
writeln;
writeln(' ');
textcolor(6);
write('Masukan Bilangan :');
readln(bil);
write('Bilangan Binernya :',decToBin(bil));
readkey;
end.
Screenshot Program :
Jika anda ingin programnya, bisa Download Disini
uses crt;
var
bil : integer;
function decToBin (desimal : integer):string;
var hasilbagi, sisa : integer;
bin : char;
bilBiner : string;
begin
hasilbagi :=desimal div 2;
bilBiner :='';
while (hasilbagi >= 1) do
begin
sisa := desimal mod 2;
if (sisa=0) then bin :='0'
else if (sisa = 1) then bin :='1';
bilBiner:=bin+bilBiner;
desimal:=hasilbagi;
hasilbagi:=desimal div 2;
end;
decToBin:='1'+bilBiner;
end;
begin
textbackground(1);
clrscr;
textcolor(4);
writeln(' ____----____----____----____----____ ');
writeln(' | | ');
writeln(' | KONVERSI BILANGAN DESIMAL KE BINER | ');
writeln(' |------------------------------------| ');
writeln(' | | ');
textcolor(5);
writeln(' | Oleh : Rhosy | ');
textcolor(4);
writeln(' |___________ --------------__________| ');
writeln;
writeln(' ');
textcolor(6);
write('Masukan Bilangan :');
readln(bil);
write('Bilangan Binernya :',decToBin(bil));
readkey;
end.
Screenshot Program :
Jika anda ingin programnya, bisa Download Disini
Post a Comment