uses crt;
var
x: integer;
begin
clrscr;
for x := 5 downto 1 do
begin
writeln (x);
end;
readln;
end.
------------------------------------------
REPEAT ... UNTIL
uses crt;
var
nilai : integer;
begin
clrscr;
nilai:=1;
repeat
writeln (nilai);
nilai:= nilai +1;
until nilai > 10;
readln;
end.
------------------------------------
FOR ... TO ... DO
uses crt;
var
begin
clrscr;
for x := 5 downto 1 do
begin
writeln (x);
end;
readln;
end.
------------------------------------------
REPEAT ... UNTIL
uses crt;
var
nilai : integer;
begin
clrscr;
nilai:=1;
repeat
writeln (nilai);
nilai:= nilai +1;
until nilai > 10;
readln;
end.
------------------------------------
FOR ... TO ... DO
uses crt;
var
a : integer;
begin
clrscr;
for a := 1 to 5 do
begin
writeln ('GUNADARMA');
end;
readln;
end.
-----------------------------------
begin
clrscr;
for a := 1 to 5 do
begin
writeln ('GUNADARMA');
end;
readln;
end.
-----------------------------------
FOR ... TO ... DO
uses crt;
var
a,b,c,d,e : integer ;
begin
clrscr ;
write ('masukkan angka : '); readln (a);
for b := 1 to a do
begin
for c := 1 to b do
begin
write (c);
end;
writeln;
end;
for d := a downto 1 do
begin
for e := 1 to (d-1) do
begin
write (e);
end;
writeln;
end;
readln;
end.
--------------------------------------------------------------
IF ... THEN
uses crt;
var
nilai : integer;
hasil : string;
begin
clrscr;
hasil = 'tidak lulus';
write ('Masukkan Nilai anda : ');readln(nilai);
if nilai >= 80 then
hasil = 'Lulus';
writeln (hasil);;
readln;
end.
-------------------------------------------------------
WHILE ... DO
uses crt;
var
y : integer;
begin
clrscr;
begin
clrscr;
y:=1;
while(y<=5) do
begin
writeln('ok ', y);
while(y<=5) do
begin
writeln('ok ', y);
y:=y+1;
end;
readln;
end.
--------------------------------------------
end;
readln;
end.
--------------------------------------------
WHILE..DO
uses crt;
var
digit: integer;begin;
clrscr;
digit := 1;
while digit <= 20 do
begin write(digit);
digit:= digit +1;
end;
readln;
end.
----------------------------------------------
CASE ...OF
uses crt;
var nilai :char;
begin;
clrscr;
write('Nilai huruf yang didpat : '); readln(nilai);
case nilai of
'A' :writeln('PIRING');
'B' :writeln('GELAS');
'C' :writeln('SENDOK');
end;
readln;
end.
-----------------------------------------------------------
0 komentar:
Posting Komentar