For…to…do
program kelipatan_3;
uses wincrt;
var i:integer;
begin
writeln('kelipatan 3 sampai 21:');
for i:=3 to 21 do
if i mod 3 =0 then
writeln(i);
end.
While…do…
Inisialisasi=1
Program whiledo1;
Uses wincrt;
Var i:byte;
Begin
Writeln('Kelipatan 7 sampai 70:');
i:=1;
While i<=70 Do
Begin
If i mod 7 = 0 then
Writeln(i);
i:=i+1;
end;
end.
Inisialisasi=0
Program whiledo0;
Uses wincrt;
Var
i:byte;
Begin
Writeln('Bilangan cacah ganjil sampai 20:');
i:=0;
While i<=20 Do
Begin
If i mod 2 = 1 then
Writeln(i);
i:=i+1;
end;
end.
Repeat…until
Inisialisasi=0
program rufaktorial;
uses wincrt;
i,n,f:integer;
begin
write('n = '); read(n);
i:=0;
f:=1;
repeat
i:=i+1;
f:=f*i;
until i=n;
writeln(n,' faktorial = ',f);
end.
Inisialisasi=1
Program ru1;
Uses wincrt;
Var x:integer;
Begin
x:=1;
repeat
writeln(x,'. Selvidiah Mutiara adalah
seorang Mahasiswi Prodi Matematika');
x:=x+1;
until x>9;
end.
2 komentar:
Artikel Menarik gan Perulangan Pascal
gambarnya (screenshoot) sekalian di post gan :)
makasih ,
Posting Komentar