Selasa, September 13, 2016

Program Pascal Mengubah Bilangan Desimal ke Bilangan Basis Lain (Basis 2 - Basis 9) Versi 2

uses crt;
var
a,b,d,e,f,g,h:integer;
c:array[1..255] of integer;

begin
clrscr;
write('masukkan sebuah bilangan desimal! ');
readln(a);
h:=a;

for g:=2 to 9 do
begin
if a<=g-1 then write(a) else

repeat
b:=b+1;
d:=trunc(a/g);
c[b]:=a mod g;
if d<=g-1 then
begin
b:=b+1;
c[b]:=d;
end;
a:=d;
until d<=g-1;

write('bilangan basis ',g,' dari bilangan desimal (basis 10) ',h,' adalah ');
for e:=b downto 1 do
begin
write(c[e]);
end;
b:=0; a:=h; writeln;
end;

readln
end.

silakan cek di http://www.convertworld.com/id/angka/Desimal.html

0 komentar: