var
x:string;
y:string[5];
begin
x:='struktur data';
y:='struktur data';
writeln(x);
writeln(y);
writeln(length(x));
writeln(length(y));
writeln(x+y);
readln;
end.
Latihan 2
var
x:integer;
begin
writeln('masukkan angka anda: ');
readln(x);
if(x<5) then
writeln('kurang dari 5')
else
writeln('lebih dari 5');
readln;
end.
Latihan 3
var
s:char;
begin
writeln('sudahkah anda berdoa hari ini? sudah(s)/belum(b)/akan(a)');
readln(s);
if (s='s') then
writeln('silahkan beraktifitas')
else
if (s='b') then
writeln('silahkan berdoa terlebih dahulu')
else
if (s='a') then
writeln('segeralah berdoa')
else
writeln('pilihan tidak ada');
readln;
end.
Latihan 4
var
s:char;
begin
writeln('sudahkah anda berdoa hari ini? sudah(s)/belum(b)/akan(a)');
readln(s);
case s of
's':writeln('silahkan beraktivitas');
'b':writeln('silahkan berdoa terlebih dahulu');
'a':writeln('segeralah berdoa');
else
writeln('pilihan tidak ada');
end;
readln;
end.
Latihan 5
var
x:integer;
begin
writeln('masukkan nilai: ');
readln(x);
case x of
90..100:writeln('A');
80..89:writeln('B');
70..79:writeln('C');
60..69:writeln('D');
else
writeln('pilihan tidak ada');
end;
readln;
end.
Latihan 6
var
x:integer;
begin
for x:=1 to 10 do
writeln(x);
readln;
end.
Latihan 7
var
x:integer;
begin
for x:=10 downto 1 do
writeln(x);
readln;
{ TODO -oUser -cConsole Main : Insert code here }
end.
Latihan 8
var
x:integer;
begin
x:=1;
repeat
writeln(x);
x:=x+1;
until x=10;
readln;
end.
Latihan 9
var
x:integer;
begin
x:=1;
while(x<=10) do
begin
writeln(x);
x:=x+1;
end;
readln;
end.
0 komentar:
Posting Komentar