Untitled
unknown
plain_text
a year ago
4.0 kB
17
Indexable
Never
program Looping; uses crt; var b,i,j,spasi,n,anak_ayam:integer; begin clrscr; {ascending to descending} { for i:=1 to 4 do begin writeln ('Hello World ke - ',i); end; writeln; } {descending to ascending} {for i:=4 downto 1 do begin writeln ('Hello World ke - ',i); end;} {writeln('============='); writeln('Lagu Anak Ayam'); writeln('============='); writeln; write('Input jumlah anak ayam:'); readln(anak_ayam); writeln; for i:=anak_ayam downto 1 do begin writeln('Anak Ayam turun ',i,' Pergi 1, tinggal ',i-1); end;} {repeat==mengulang} {until==sampai} {i:=0; repeat begin writeln('hello world ke ',i,' + ',1,' = ',i+1); i:=i+1; end; until i=10;} { for i:=1 to 5 do begin for j:=1 to 5 do writeln(' i = ',i,' * ',' j = ',j,' hasil ',i*j); end} {latihan soal 1 part 1} {soal part 1 nomor 1 Pseudocode} START i:integer; for i <-1 to 10 do for i <-1 to 10 do write('* '); endfor endfor END { for i:=1 to 10 do begin for j:=i to 10 do begin write('* '); end; writeln; end;} {latihan soal 2 part 1 4 2 222 22222 } n:=10; {soal part 1 nomor 2 segitiga Pseudocode} START i:integer; n:integer; spasi:integer; i <- 1; n <- 10; spasi <- 1; j <- 1; for i to n do if(i mod 2 = 1) for spasi to n-1 write('*'); write(' '); endfor for j to i write('*'); write(' '); endfor writeln; endfor END {segitiga for i:=1 to n do begin if(i mod 2=1) then begin for spasi:=1 to n-i do begin write(' '); end; for j:=1 to i do begin write('*'); write(' '); end; writeln; end; end; } {soal part 1 nomor 2 segitiga Pseudocode} START i:integer; n:integer; spasi:integer; for i:=1 to n for spasi:=1 to n-i write(' '); endfor for j:=1 to 2*i-1 write('*'); endfor writeln; endfor for i:=n-1 downto 1 for spasi:=1 to n-i write(' '); endfor for j:=1 to 2*i-1 write('*'); endfor writeln; endfor {belahketupat 1 * 2 - 1 = 1 2 * 2 - 1 = 3 3 * 2 - 1 = 5 2 * 2 - 1 = 3 1 * 2 - 1 = 1 } for i:=1 to n do begin for spasi:=1 to n-i do begin write(' '); end; for j:=1 to 2*i-1 do begin write('*'); end; writeln; end; for i:=n-1 downto 1 do begin for spasi:=1 to n-i do begin write(' '); end; for j:=1 to 2*i-1 do begin write('*'); end; writeln; end; {for i:=1 to 4 do begin for j:=1 to i do begin write(i); end; writeln; end;} for i:=4 downto 1 do begin for j:=i downto 1 do begin write(j); end; writeln; end; end.