1)
Program Huruf
program huruf;
uses wincrt;
var
data:char;
begin
readln(data);
case
data of
'a',
'i', 'u', 'e', 'o' : writeln ('huruf kecil vokal');
else
writeln
('bukan huruf vokal');
('bukan huruf vokal');
end;
end.
2) Program Segitiga Pascal
program segitiga_pascal;
uses wincrt;
var
input,i,j : word;
isi: array [0..20,0..21] of word;
begin
writeln ('Masukkan berapa tingkat segitiga
pascal!');
readln (input);
isi [0,1] := 1;
for i:= 1 to input do
begin
for j:= 1 to i + 1 do
begin
isi [i,j]:= isi[i-1,j] + isi[i-1,j-1];
write (isi [i,j],' ');
end;
writeln;
end;
end.
3)
Program Persegi
program persegi;
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.
4)
Program Perpangkatan
program perpangkatan;
uses wincrt;
var
i, o, n : longint;
hasil : real;
begin
writeln ('a pangkat b');
writeln
('masukkan a='); readln (o);
writeln
('masukkan b='); readln (n);
hasil
:= 1;
for
:= 1 to abs(n) do
hasil
:= o*hasil;
if
(n<0) then
begin
write
('hasil='): write (1/hasil);
end;
else
begin
write
('hasil='); write (hasil);
end;
end.
Tidak ada komentar:
Posting Komentar