program menghitung_umur;
uses wincrt;
var nama: string;
umur,TL: integer;
begin
writeln ('nama :'); readln (nama);
writeln ('tahun lahir :'); readln (TL);
writeln ('umur :');
umur:=2011-TL;
writeln (umur);
end.
program deret_angka;
uses wincrt;
var a: integer;
begin
a:=1;
write(1); write(' ');
repeat
a:=a+3;
write(a); write(' ');
until a=16;
end.
program belajar ;
uses wincrt;
var
i,j:integer;
begin
for i:=1 to 5 do
begin
for j:=1 to i do
write(j,' ');
writeln;
end;
end.
program belajar ;
uses wincrt;
var
i,j:integer;
begin
for i:=5 downto 1 do
begin
for j:=1 to i do
write(j,' ');
writeln;
end;
end.
program faktorial;
uses wincrt;
var i,n,f :integer;
begin
readln (n); f:=1; i:=0;
repeat
i:= i+1;
f:=f*i;
until i=n;
writeln (n, 'faktorial= ',f);
end.
program faktorial;
uses wincrt;
var
i,n,jumlah: integer;
begin
jumlah:=1;
write ('inputkan suatu nilai :'); readln (n);
write ('faktorial dari ',n,' adalah:');
for i:= n downto 2 do
begin
write (i,'x');
jumlah:=i*jumlah;
end;
begin
if n<0 then write ('tidak terdefinisi')
else write (1,'=',jumlah);
end;
end.
program deret;
uses wincrt;
var i,j,k,n,r:integer;
begin readln (n);
for i:=1 to n do
begin
for j:=1to i do
k:=1;
for r:=1 to j do
begin
k:=j*k;
write (k);
write(' ');
end;
writeln(' ');
end;
end.
program pp;
uses wincrt;
var i,n,j :integer;
begin
readln(n);
for i:=n downto 1 do
begin
for j:=1 to n do
begin if (j<i) then
write(' ')
else
write('*');
write(' ');
end;
writeln(' ');
end;
end.
program lina;
uses winCrt;
procedure gb (brs,kol:integer);
var i,j:integer;
begin
for i:=1 to brs do
begin
for j:=1 to kol do
begin
if ((i=1)or(i=brs)or(j=1)or(j=kol))then
write ('*')
else write(' ');
end;
writeln;
end;
end;
var x,y:integer;
begin
write('banyak baris= ');readln(y);
write('banyak kolom= ');readln(x);
writeln('bentuknya:');
gb(y,x);
end.
Tidak ada komentar:
Posting Komentar