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

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.

BACA JUGA :  REKAMAN : SEMINAR ONLINE PENDIDIKAN | DINAS PENDIDIKAN KABUPATEN DELI SERDANG BEKERJASAMA DENGAN SMP NEGERI 1 LABUHAN DELI
Tags
About The Author

Leave a reply

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