Penggunaan While, For dan Repeat pada Pascal
Contoh Penggunaan While, For & Repeat pada Pascal...
Program Contohfor;
uses crt;
var
c,r,f: real;
i : integer;
begin
clrscr;
writeln('');
writeln('Tabel Konversi Suhu');
writeln('========================================');
writeln('||Celcius Reamur Farenheit||');
writeln('========================================');
c:=10;
for i:=1 to 5 do
begin
write(c:6:0);
r:=c*0.8; f:=c*1.8+32;
writeln(' ',r:6:2,' ',f:6:2);
c:=c+5;
end;
writeln('========================================');
readln;
end.
Program Contohrepeat;
uses crt;
var
c,r,f: real;
i : integer;
begin
clrscr;
writeln('');
writeln('Tabel Konversi Suhu');
writeln('========================================');
writeln('||Celcius Reamur Farenheit||');
writeln('========================================');
c:=10;
repeat
write(c:6:0);
r:=c*0.8; f:=c*1.8+32;
writeln(' ',r:6:2,' ',f:6:2);
c:=c+5;
until c>30;
writeln('========================================');
readln;
end.
Program Contohwhile;
uses crt;
var
c,r,f: real;
i : integer;
begin
clrscr;
writeln('');
writeln('Tabel Konversi Suhu');
writeln('========================================');
writeln('||Celcius Reamur Farenheit||');
writeln('========================================');
c:=10;
while c<=30 do
begin
write(c:6:0);
r:=c*0.8; f:=c*1.8+32;
writeln(' ',r:6:2,' ',f:6:2);
c:=c+5;
end;
writeln('========================================');
readln;
end.
Program Contohfor;
uses crt;
var
c,r,f: real;
i : integer;
begin
clrscr;
writeln('');
writeln('Tabel Konversi Suhu');
writeln('========================================');
writeln('||Celcius Reamur Farenheit||');
writeln('========================================');
c:=10;
for i:=1 to 5 do
begin
write(c:6:0);
r:=c*0.8; f:=c*1.8+32;
writeln(' ',r:6:2,' ',f:6:2);
c:=c+5;
end;
writeln('========================================');
readln;
end.
Program Contohrepeat;
uses crt;
var
c,r,f: real;
i : integer;
begin
clrscr;
writeln('');
writeln('Tabel Konversi Suhu');
writeln('========================================');
writeln('||Celcius Reamur Farenheit||');
writeln('========================================');
c:=10;
repeat
write(c:6:0);
r:=c*0.8; f:=c*1.8+32;
writeln(' ',r:6:2,' ',f:6:2);
c:=c+5;
until c>30;
writeln('========================================');
readln;
end.
Program Contohwhile;
uses crt;
var
c,r,f: real;
i : integer;
begin
clrscr;
writeln('');
writeln('Tabel Konversi Suhu');
writeln('========================================');
writeln('||Celcius Reamur Farenheit||');
writeln('========================================');
c:=10;
while c<=30 do
begin
write(c:6:0);
r:=c*0.8; f:=c*1.8+32;
writeln(' ',r:6:2,' ',f:6:2);
c:=c+5;
end;
writeln('========================================');
readln;
end.
Comments
Post a Comment
Terimakasih telah berkunjung dan berkomentar disini...