Program untuk menampilkan :
11
21 22
31 32 33
41 42 43 44
51 52 53 54 55
PROGRAM NASTED_WHILE;
USES WINCRT;
VAR
I, J, BILANGAN : INTEGER;
BEGIN
I := 1;
WHILE I <= 5 DO
BEGIN
J := 1;
BILANGAN := 0;
BILANGAN := (BILANGAN + I);
WHILE J <= BILANGAN DO
BEGIN
WRITE (I:3,J);
J := J + 1;
END;
WRITELN;
I := I + 1;
END;
END.
PROGRAM NASTED_FOR;
USES WINCRT;
VAR
I, J, bilangan : INTEGER;
BEGIN
bilangan := 0;
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_REPEAT;
USES WINCRT;
VAR
I, J, bilangan : INTEGER;
BEGIN
I := 1;
bilangan := 1;
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.
Tidak ada komentar:
Posting Komentar