Selasa, 20 Maret 2012

contoh Pengulanagan program pascal


* Pengulangan For

· program pascal_aritha;
uses wincrt;
var i : integer;
begin
writeln('=============Program Perulangan=============');
writeln(' ======By ArF=====');
for i := 1 to 5 do writeln('aku ganteng');
end.

· Program pascal_aritha;
uses wincrt;

Var I:integer;

Begin

For I:=5 downto 1 do

Begin

Writeln(I);

End;

End.

* Pengurangan While

· program pengulangan;

uses crt;

var

s,L:integer;

ulang:char;

begin

clrscr;

ulang:='y';

while ulang='y' do

begin

clrscr;

writeln('Menghitung Bujur Sangkar');

writeln('------------------------');

write('Masukkan sisi: ');readln(s);

L:=s*s;

writeln('Luas adalah ',L);

writeln;

write('Apakah Mau diulang (y/t)? ');read(ulang);

end;

readln;

end.

· program coba;

uses crt;

var

i:integer;

begin

clrscr;

i:=1;

while i<=10 do

begin

write(i,' ')

i:=i+1;

end;

readln;

end.

* Pengurangan Repeat Until

· Program coba;
uses wincrt;

Var

I:Integer

Begin

I:=0;

Repeat

I:=I+1;

Writeln(I);

Until I=5;

End.

· program pascal_aritha;

uses wincrt;

var i : integer;

begin
i:=5;
repeat
write(i,' ');
if i mod 20 = 0 then writeln;
i:=i+5;
until i>=61;
end.

Categories: ,

0 komentar:

Posting Komentar