Saturday, December 22, 2012

Contoh Kode Program Pengulangan Dengan Pascal

Pengulangan dengan For To Do

Program pengulangan;
var
i : integer;
N:  integer;
writeln ( ‘Isi nilai N’);
write (‘N=‘);
readln(N);
for i := 1 to N do
begin
writeln (i);
end;
writeln (‘Akhir Program’);
end.

Pengulangan dengan While

Program pengulangan;
var
i : integer;
N:  integer;
writeln ( ‘Isi nilai N’);
write (‘N=‘);
readln(N);
i := 1;
While ( i <= N) do;
begin
writeln (i);
i:= i+1;
end;
writeln (‘Akhir Program’);
end.

Pengulangan dengan Repeat

Program pengulangan;
var
i : integer;
N:  integer;
Stop : boolean;
writeln ( ‘Isi nilai N’);
write (‘N=‘);
readln(N);
i := 1;
Stop := False;
Repeat
writeln (i);
If (i=N) then stop := True else
begin
i:= i+1;
end;
Until stop;
writeln (‘Akhir Program’);
end.


Sumber : http://medibatam.wordpress.com/2011/11/09/contoh-kode-program-pengulangan-dengan-pascal/

Post a Comment

Followers

English French German Spain Italian Dutch Russian Portuguese Japanese Korean Arabic Chinese Simplified


  © Blogger template 'A Click Apart' by Ourblogtemplates.com 2008

Back to TOP