CONTOH PROGRAM MENGHITUNG NILAI PHI
program menghitung_phi;
uses wincrt ;
var
hasil :real;
begin
hasil:=22/7;
writeln(hasil);
end.
CONTOH PROGRAM BENTUK MATRIK
program matriks;
uses wincrt;
var
x:array[1..100,1..100] of integer;
p,l,i,j:integer;
begin
write('banyaknya kolom = '); read(p);
write('banyaknya baris = '); read(l);
writeln('tulis kebawah sebanyak baris kali kolom');
for i:=1 to l do
for j:=1 to p do
readln(x[i,j]);
writeln('bentuk matriknya : ');
for i:=1 to l do
begin
for j:=1 to p do
write(x[i,j],' ');
writeln;
end;
end.
program matriks;
uses wincrt;
var
x:array[1..100,1..100] of integer;
p,l,i,j:integer;
begin
write('banyaknya kolom = '); read(p);
write('banyaknya baris = '); read(l);
writeln('tulis kebawah sebanyak baris kali kolom');
for i:=1 to l do
for j:=1 to p do
readln(x[i,j]);
writeln('bentuk matriknya : ');
for i:=1 to l do
begin
for j:=1 to p do
write(x[i,j],' ');
writeln;
end;
end.
CONTOH PROGRAM KONVERSI BINER KE ANGKA
Program konversi_biner;
uses wincrt;
var
desimal,b,sisa,biner:integer;
begin
write (' angka biner '); readln (biner);
b:=0;
repeat
sisa:= biner mod 10;
biner:= biner div 10;
if (b=0) then
b:=1
else
b:=b*2;
desimal:= desimal+sisa*b;
until biner = 0;
write ('desimal=', desimal );
end.
Program konversi_biner;
uses wincrt;
var
desimal,b,sisa,biner:integer;
begin
write (' angka biner '); readln (biner);
b:=0;
repeat
sisa:= biner mod 10;
biner:= biner div 10;
if (b=0) then
b:=1
else
b:=b*2;
desimal:= desimal+sisa*b;
until biner = 0;
write ('desimal=', desimal );
end.
Langganan:
Postingan (Atom)