Ari Usman Chaniago
Berbagi itu Indah
Program konversi_Desimal_to_Biner;
uses crt;
var bilangan: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
clrscr;
writeln(‘KONVERSI BILANGAN DESIMAL KE BINER’);
writeln;
write(‘masukkan bilangan : ‘);readln(bilangan);
write(‘Bilangan Binernya : ‘, decToBin(bilangan));
readkey;
end.