21 Februari 2011

Membuat Program Pengulangan FOR dengan Free Pascal

program perulangan_for;
uses crt;
var
i,batas : integer;
begin
clrscr;
write ('masukkan batas akhir = ');
read (batas);
for i := 1 to batas do
begin
if i mod 3 = 0 then
write (i,' ');
end;
readln;
readln;
end.

2. program perulangan while

program perulangan_while;
uses crt;
var
i,batas : integer;
begin
clrscr;
write ('masukkan batas akhir = ');
read (batas);
i := 1;
while i <= batas do
begin
if (i mod 2 <> 0 ) AND (i mod 3 = 0) then
write (i, ' ');
i := i + 1;
end;
readln;
readln;
end.

Tidak ada komentar:

Posting Komentar