IF ELSE
var
a:integer;
begin
write('Berapa tinggi badanmu? [cm] ');
readln(a);
if (a>=100) and (a<=150) then
writeln('Anda Pendek')
else
if (a>=151) and (a<=169) then
writeln('Tinggi badan Ideal')
else
if (a>=170) and (a<=200) then
writeln('Anda Tinggi');
readln;
end.
var
a:integer;
begin
write('Berapa kali kamu membolos? ');
readln(a);
if a>=5 then
writeln('Kamu tidak boleh mengikuti ujian')
else
writeln('Silahkan persiapkan diri untuk ujian');
readln;
end.
var
a:string;
begin
write('Sudahkan anda belajar untuk ujian? [sudah/belum] ');
readln(a);
if a='sudah' then
writeln('segera istirahat')
else
writeln('belajarlah');
readln;
end.
CASE OF
var
a:integer;
begin
write('Tuliskan sebuah angka [1-10] ');
readln(a);
case a of
1:writeln('Satu');
2:writeln('Dua');
3:writeln('Tiga');
4:writeln('Empat');
5:writeln('Lima');
6:writeln('Enam');
7:writeln('Tujuh');
8:writeln('Delapan');
9:writeln('Sembilan');
10:writeln('Sepuluh');
end;
readln;
end.
var
a:integer;
begin
write('Berapa nilai Struktur Datamu? ');
readln(a);
case a of
90..100:writeln('Baik Sekali');
80..89:writeln('Baik');
70..79:writeln('Cukup');
60..69:writeln('Belajarlah lagi');
0..59:writeln('Kamu tidak sungguh-sungguh');
end;
readln;
end.
var
a:integer;
begin
write('Berapa jam waktu internetmu? ');
readln(a);
case a of
1:writeln('Tarif 3000');
2:writeln('Tarif 5000');
3:writeln('Tarif 7000');
end;
readln;
end.
FOR TO DO
var
x:integer;
begin
for x:=50 to 60 do
if (x<>51) and (x<>58) then
writeln(x);
readln;
end.
var
x:integer;
begin
for x:=100 downto 90 do
if (x<>95) and (x<>91) then
writeln(x);
readln;
end.
var
baris,kolom,jml:integer;
begin
write ('Jumlah Baris : ');
readln(jml);
for baris:=1 to jml do
begin
write ('#': jml);
for kolom := 2 to (2 *baris -1 ) do
begin
write('#');
end;
readln;
end;
end.
REPEAT UNTIL
var
x:integer;
begin
x:=2;
repeat
writeln(x);
x:=x+2;
until x=10;
readln;
end.
var
x:integer;
begin
x:=5;
repeat
writeln(x);
x:=x+5;
until x=30;
readln;
end.
var
x:integer;
begin
x:=10;
repeat
writeln(x);
x:=x+10;
until x>50;
readln;
end.
WHILE DO
var
x:integer;
begin
x:=3;
while(x<=18) do
begin
writeln(x);
x:=x+3;
end;
readln;
end.
var
x:integer;
begin
x:=5;
while(x<=30) do
begin
writeln(x);
x:=x+5;
end;
readln;
end.
var
x:integer;
begin
x:=2;
while(x<=12) do
begin
writeln(x);
x:=x+2;
end;
readln;
end.
2 komentar:
mantap postingannya.. wajib di follow
haha, makasih :D
Posting Komentar