Rizka dewi
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.
seperti pada gambar:
Rizka dewi
program dimensi;
uses wincrt;
var
x:array[1..100,1..100]of integer;
p,l,i,j:integer;
begin
write('p= ');readln(p);
write('l= ');readln(l);
for i:=1 to l do
for j:=1 to p do
readln(x[i,j]);
writeln;
writeln('Bentuk Matriknya');
for i:=1 to l do
begin
for j:=1 to p do
write (x[i,j],' ') ;
writeln;
end;
writeln('Bentuk Matrik transposenya');
for i:=1 to p do
begin
for j:=1 to l do
write (x[j,i],' ') ;
writeln;
end;
end.
seperti:
Rizka dewi
Program Fibonacci;
Uses wincrt;
var
a,b,c,i,n :integer;
begin
write('masukkan n= ');readln(n);
a:=1 ; b:=0 ;
for i := 1 to n do
begin
c:=a+b;
a:= b;
b:= c;
write(c, ' ');
end;
end.
Rizka dewi
program hitung_umur;
uses wincrt;
var
nama:string;
umur,tahun:integer;
begin
writeln('masukkan nama:');readln(nama);
writeln('masukkan tahun lahir:');readln(tahun);
umur:=2011-tahun;
write('umur:');writeln(umur);readln(umur);
end.
seperti pada gambar:
Rizka dewi
program kombinasi_faktorial;
uses wincrt;
var
fn,fx,fn_x,Kombinasi:real;
i,n,x:integer;
begin
write('Masukkan bilangan n =');
readln(n);
write('Masukkan bilangan x =');
readln(x);
fn:=1;
fx:=1;
fn_x:=1;
for i:= 2 to n do
fn:=fn*i;
for i := 2 to x do
fx:=fx*i;
for i:= 2 to (n-x) do
fn_x:=fn_x*i;
kombinasi:=fn/(fx*fn_x);
writeln(n,' Kombinasi ',x, ' = ',Kombinasi:0:0);