Program konversi_Desimal_ke_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.
|
This entry was posted on 12:29 PM and is filed under . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
0 comments: