Program DESIMAL_TO_BINER;
uses wincrt;
var
hasilbagi, desimal,sisa: integer;
biner,bin, bilbiner: string;
begin
writeln(' ------------------------------------ ');
writeln(' KONVERSI DESIMAL KE BINER ');
writeln(' ------------------------------------ ');
writeln;
write (' Desimal = ');readln(desimal);
writeln;
hasilbagi:= desimal div 2;
bilbiner := ' ';
while (hasilbagi >= 1 ) do
begin
sisa := desimal mod 2;
if (sisa=0) then
biner := '0'
else
if (sisa=1) then
biner := '1';
bilbiner := biner+bilbiner;
desimal := hasilbagi;
hasilbagi := desimal div 2;
end;
bin := '1' + bilbiner;
writeln (' biner = ', bin);
writeln(' ------------------------------------ ');
end.
Artikel Terkait:
0 komentar:
Posting Komentar