Pascal : Coding Konversi Desimal to Biner
December 21, 2019 No Comments Ari Usman,Artikel Komputer,Pascal admin

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.

BACA JUGA :  SALAM YANG TAK TERGANTIKAN
Tags
About The Author

Leave a reply

Your email address will not be published. Required fields are marked *