Program untuk menampilkan :
Cara mendapatkan output
11 12 13 14 15
21 22 23 24
31 32 33
41 42
51
PROGRAM NASTED_REPEAT;
USES WINCRT;
VAR
I, J, bilangan : INTEGER;
BEGIN
I := 1;
bilangan := 5;
REPEAT
J := 1;
REPEAT
WRITE (I:3,J);
J := J + 1;
UNTIL
J > bilangan;
bilangan := (bilangan - 1);
WRITELN;
I := I + 1;
UNTIL
I > 5;
END.
PROGRAM NASTED_FOR;
USES WINCRT;
VAR
I, J, bilangan : INTEGER;
BEGIN
bilangan := 6;
FOR I := 1 TO 5 DO
BEGIN
bilangan := (bilangan - 1);
FOR J := 1 TO bilangan DO
WRITE (I:3,J);
WRITELN;
END;
END.
PROGRAM NASTED_WHILE;
USES WINCRT;
VAR
I, J, BILANGAN : INTEGER;
BEGIN
I := 1;
WHILE I <= 5 DO
BEGIN
J := 1;
BILANGAN := 6;
BILANGAN := (BILANGAN - I);
WHILE J <= BILANGAN DO
BEGIN
WRITE (I:3,J);
J := J + 1;
END;
WRITELN;
I := I + 1;
END;
END.
Tidak ada komentar:
Posting Komentar