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

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.

Visited 16 times, 1 visit(s) today
Tags
About The Author
Ari Usman Seorang Praktisi IT di Bidang Digital Marketing dan Dosen di Bidang Teknik Informatika

Leave a reply

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