RSS

Contoh Perulangan dengan Penerapan Statemen For.. Do..

06 Jun

Berikut ini adalah sebagian contoh perulangan dengan penerapan statemen For.. Do..

Uses Wincrt;
const
akhir = 4;
var
baris,kolom : integer;
begin
for baris := akhir downto 1 do
begin
for kolom := baris downto 1 do
write(kolom);
writeln;
end;
end.

Hasil :
4321
321
21
1


Uses Wincrt;
const
akhir = 4;
var
baris,kolom : integer;
begin
for baris := akhir downto 1 do
begin
for kolom := 1 to baris do
write(kolom);
writeln;
end;
end.

Hasil :
1234
123
12
1


Uses Wincrt;
const
akhir = 4;
var
baris,kolom : integer;
begin
for baris := 1 to akhir do
begin
for kolom := 1 to baris do
write(baris);
writeln;
end;
end.

Hasil :
1
22
333
4444


Uses Wincrt;
const
akhir = 4;
var
baris,kolom : integer;
begin
for baris := akhir downto 1 do
begin
for kolom := baris downto 1 do
write(baris);
writeln;
end;
end.

Hasil :
4444
333
22
1


Uses Wincrt;
const
akhir = 3;
var
baris,kolom : integer;
begin
for baris := akhir downto 1 do
begin
for kolom := baris downto 1 do
write(baris,' ',kolom);
writeln;
end;
end.

Hasil :
3 33 23 1
2 22 1
1 1


Uses wincrt;
var baris,kolom,jumbaris :integer;
begin
write ('Jumlah Baris : ');readln(jumbaris);
FOR BARIS:=1 TO jumbaris do
begin
write ('*': jumbaris baris);
FOR kolom := 2 TO (2 *baris -1 ) do
begin
write('*');
end;
writeln;
end;
end.

Hasil :
(baris = 4)
*
***
*****
*******

 
Tinggalkan komentar

Ditulis oleh pada Juni 6, 2012 in PEMPROGRAMAN

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: