PENGUNJUNG BLOG

Cari Blog Ini

Kamis, 12 April 2012

Program Pascal to...do , downto...do

uses crt;
var a,b : integer;
begin
clrscr;
for a:= 1 to 4 do
begin
for b:= 1 to a do
write (b*2);
writeln;
end;
readln;
end.


Outputnya :
2
24
246
2468



uses crt;
var a,b : integer;
begin
clrscr;
for a:= 4 downto 1 do
begin
for b:= 1 to a do
write (b*2-1);
writeln;
end;
readln;
end.

Output :
1357
135
13
1



uses crt;
var x,y,z : integer;
begin
clrscr;
z := 0;
for x:= 1 to 3 do
begin
for y:= 1 to x do
begin
z := z + 1;
write (z,' ');
end;
writeln;
end;
readln;
end.



Output :
1
23
456

Tidak ada komentar:

Posting Komentar

Powered By Blogger