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);
Rizka dewi
Program hitung_nilai;
uses wincrt;
var
a:integer;
begin
readln(a);
case a of 81..100:writeln ('A');
76..80 :writeln ('AB');
70..75:writeln ('B');
61..70:writeln ('BC');
51..60:writeln ('C');
41..50:writeln ('D');
0..40:writeln ('E');
else writeln('input nilai salah');
end;
end.
seperti pada gambar:
Rizka dewi
program binomial;
uses wincrt;
var
i,j,k,n,x:longint;
a,b,c,d,e,p:real;
begin
readln (n);
readln(x);
readln(p);
a:=1;b:=1;c:=1;d:=1;e:=1;
for i:=1 to n do
a:=a*i;
for j:=1 to x do
begin
b:=b*j;
c:=c*p;
end;
for k:=1 to (n-x) do
begin
d:=d*k;
e:=e*(1-p);
end;
writeln(a/(b*d)*c*e:0:4);
end.
seperti pada gambar:
Rizka dewi
program perpangkatan;
uses wincrt;
var i,o,p:longint;
hasil:real;
begin writeln('a pangkat b');
writeln('masukkan a=');readln(o);
writeln('masukkan b=');readln(p);
hasil:=1;
for i:=1 to abs(p) do
hasil:=o * hasil;
if (p<0) then
begin
write('hasil=');
write(1/hasil);
end
else
begin
write('hasil= ');
write(hasil);
end;
end.
Rizka dewi
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.