Rabu, 13 Januari 2016

Pascal Perulangan


1. program tugas11;
uses wincrt;

var
a, b : byte;

begin

for a := 1 to 5 do
begin
writeln('   ',a);
b := b+a;
end;
writeln('------ +');
writeln('   ',b);
readln;
end.

-------------------------

program tugas12;
uses wincrt;

var
a, b : byte;

begin
a:=1;
b:=0;

while a<6 do

begin

writeln('   ',a);
b := b+a;
a := a+1;


end;

writeln('------ +');
writeln('   ',b);

readln;

end.

-------------------

program tugas13;
uses wincrt;

var
a, b : byte;

begin

a := 1;
b := 0;
begin

repeat

Writeln(a);

b := b+a;
a := a+1;

until a>5;

end;
writeln('------- +');
writeln('   ',b);

readln;

end.


2. program tugas21;
uses wincrt;

var
a, b : byte;

begin

for a := 1 to 10 do
if a mod 2=1 then

begin
writeln('   ',a);
b := b+a;

end;

writeln('------ +');
writeln('   ',b);
readln;

end.

-----------------

program tugas22;
uses wincrt;

var
a, b : byte;

begin
a:=1;
b:=0;

while a<10 do

begin
if a mod 2=1 then
writeln('   ',a);
if a mod 2=1 then
b := b+a;
a := a+1;


end;

writeln('------ +');
writeln('   ',b);

readln;

end.

-------------------

program tugas23;
uses wincrt;

var
a, b : byte;

begin

a := 1;
b := 0;

begin

repeat

if a mod 2=1 then

Writeln('   ',a);
if a mod 2=1 then
b := b+a;
a := a+1;

until a>10;

end;
writeln('------- +');
writeln('   ',b);

readln;

end.


3. program tugas31;
uses wincrt;

var
a, b : byte;

begin

for a := 1 to 5 do
begin
for b := 1 to 3 do
write(b:3);
writeln;
end;

readln;

end.

------------
program tugas32;
uses wincrt;

var
a, b : byte;

begin

a:=1;
b:=1;

while a<6 do

begin

b:=1;

while b<4 do

begin

write(b:3);

b := b+1;

end;

a := a+1;
writeln;
end;


readln;

end.


4. program tugas41;
uses wincrt;

var
a, b : byte;

begin

for a := 1 to 6 do
begin
for b := 1 to a do
write('x');
writeln;
end;

readln;

end.

----------------------
program tugas42;
uses wincrt;

var
a, b : byte;

begin

a:=1;
b:=1;

while a<8 do

begin

b:=1;

while b<a do

begin

write('x');

b := b+1;

end;

a := a+1;
writeln;
end;


readln;

end.


5.program tugas51;
uses wincrt;

var
a, b : byte;

begin

for a := 1 to 5 do
begin
for b := 1 to 3 do
write(a:3);
writeln;
end;

readln;

end.

-------------

program tugas52;
uses wincrt;

var
a, b : byte;

begin

a:=1;
b:=1;

while a<6 do

begin

b:=1;

while b<4 do

begin

write(a:3);

b := b+1;

end;

a := a+1;
writeln;
end;


readln;

end.

------------

program tugas53;
uses wincrt;

var
a, b, c : byte;

begin

a := 1;

repeat

b := 1;

repeat

c := 1;

repeat

Writeln(a:3,b:3,c:3);

b := b+1;
a := a+1;
c := c+1;

until a>5;
until b>5;
until c>5;

readln;

end.


6. program tugas61;
uses wincrt;

var
a, b : byte;

begin

for a := 1 to 5 do
begin
for b := 1 to a do
write(a:3);
writeln;
end;

readln;

end.

---------------

program tugas62;
uses wincrt;

var
a, b : byte;

begin

a:=0;
b:=0;

while a<6 do

begin

b:=0;

while b<a do

begin

write(a:3);

b := b+1;

end;

a := a+1;
writeln;
end;


readln;

end.
 

0 komentar:

Posting Komentar