program pelajar;
uses wincrt;
var
A,B,hasil:integer;
begin
A:=10;
B:=2;
hasil:=A div B;
A:=10;
B:=2;
hasil:=A mod B;
A:=10;
repeat
A:=A div B;
writeln (hasil);
hasil:=A mod B;
until A=0;
end.
program pelajar;
uses wincrt;
var
A,B,hasil:integer;
begin
write ('biner = ');readln (b);
if (b mod 2)=1 then
write ('0')
else
write ('1');
A:=10;
B:=2;
hasil:=A div B;
A:=10;
B:=2;
hasil:=A mod B;
A:=10;
repeat
A:=A div B;
write (hasil);
hasil:=A mod B;
until A=1;
end.
program pascal;
uses wincrt;
var b:integer;
begin
write('Bilangan = ');readln(b);
if (b mod 2)=1 then
write('ganjil')
else
write('genap');
end.
program pascal;
uses wincrt;
var desimal,d,sisa,biner:longint;
begin
write ('biner= ');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.
program pascal;
uses wincrt;
var desimal,d,sisa,biner:longint;
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.
Tidak ada komentar:
Posting Komentar