TUGAS SOD 2(membuat operasi string dalam pascal)
uses crt;
var x: integer;
z:integer;
jawab:char;
h,i,j,k:string;
begin
repeat
clrscr;
writeln('menu operator string');
writeln('1.menggabungkan string:');
writeln('2.menghitung panjang string:');
writeln('3.menyisipkan string:');
writeln('<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>');
writeln('masukkan pilihan anda:');
readln(x);
case x of
1:begin
write('kata1:');readln(h);
write('kata2:');readln(i);
write('kata3:');readln(j);
k:=concat(h,i,j);
writeln(k);
end;
2:begin
write('kata1:');readln(h);
write('kata2:');readln(i);
write('kata3:');readln(j);
k:=concat(h,i,j);
z:=length(k);
writeln('panjang string :',z);readln;
end;
3:begin
write('kata1:');readln(h);
write('kata2:');readln(i);
write('kata3:');readln(j);
k:=concat(h,i,j);
insert('&',k,10);
writeln(k);readln(k);
end;
end;
write('apakah anda ingin mengulanginya?(y/n);');
readln(jawab);
until(jawab='n');
end.
var x: integer;
z:integer;
jawab:char;
h,i,j,k:string;
begin
repeat
clrscr;
writeln('menu operator string');
writeln('1.menggabungkan string:');
writeln('2.menghitung panjang string:');
writeln('3.menyisipkan string:');
writeln('<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>');
writeln('masukkan pilihan anda:');
readln(x);
case x of
1:begin
write('kata1:');readln(h);
write('kata2:');readln(i);
write('kata3:');readln(j);
k:=concat(h,i,j);
writeln(k);
end;
2:begin
write('kata1:');readln(h);
write('kata2:');readln(i);
write('kata3:');readln(j);
k:=concat(h,i,j);
z:=length(k);
writeln('panjang string :',z);readln;
end;
3:begin
write('kata1:');readln(h);
write('kata2:');readln(i);
write('kata3:');readln(j);
k:=concat(h,i,j);
insert('&',k,10);
writeln(k);readln(k);
end;
end;
write('apakah anda ingin mengulanginya?(y/n);');
readln(jawab);
until(jawab='n');
end.
Komentar
Posting Komentar