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

Program konversi_Biner_to_Dec;
uses crt;
var bilBiner : String;

function pangkat(a, b : integer): integer;
var i, hasil : integer;
begin
hasil := 1;
for i:=1 to b do
begin
hasil := hasil * a;
end;
pangkat := hasil;
end;

function bin2Dec(biner : string) : integer;
var n, sum, i : integer;
begin
n := length(biner);
sum := 0;
for i := n-1 downto 0 do
begin
if (biner [n-1] = ‘0’) then sum := sum + 0 * pangkat (2, i)
else if (biner [n-1] = ‘1’) then sum := sum + 1 * pangkat (2, i);
end;
bin2Dec := sum;
end;

begin
clrscr;
writeln(‘KONVERSI BILANGAN BINER KE DESIMAL’);
writeln;
write(‘Masukkan bilangan Biner : ‘);readln(bilBiner);
write (‘Bilangan Desimalnya : ‘, bin2Dec(bilBiner));
readkey;
end.

Visited 3 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 *