LOGO

Minggu, 18 Desember 2011

program pascal biner

Alhamdulillah,,, akhirnya final juga tugas UAS PIK ^__-

Pacu prestasimu!!

program PASCAL-Bilangan Biner

PROGRAM UBAH BINER-DESIMAL dan DESIMAL-BINER

program biner_ke_desimal;
uses wincrt;
var
biner,desimal,sisa,b :longint;
begin
desimal:=0;b:=1;
write(' angka biner ');readln(biner);
b:=1;
repeat
sisa:=biner mod 10;
biner:=biner div 10;
desimal:=desimal+sisa*b;
b:=b*2;
until biner=0;
write(' angka desimal ');writeln(desimal);
end.

program konversi_biner;
uses wincrt;
var desimal,d,sisa,biner:integer;
begin
write('angka desimal='); readln(desimal);
d:=0;
repeat
sisa:=desimal mod 2;
desimal:=desimal div 2;
if(d=0) then
d:=1
else
d:=d*10;
biner:=biner+sisa*d;
until desimal=0;
write('biner=',biner);
end.

0 komentar:

Posting Komentar