soal 4
program Soal4;
uses crt;
function terbilang(x:longint):string;
function bilang(x:longint):string;
begin
case x of
0:bilang:='';
1:bilang:=' satu ';
2:bilang:=' dua ';
3:bilang:=' tiga ';
4:bilang:=' empat ';
5:bilang:=' lima ';
6:bilang:=' enam ';
7:bilang:=' tujuh ';
8:bilang:=' delapan ';
9:bilang:=' sembilan ';
10:bilang:=' sepuluh ';
11:bilang:=' sebelas ';
end;
end;
begin
if x<12 then
terbilang:=''+bilang(x)
else if x<20 then
terbilang:=terbilang(x-10)+'belas'
else if x<100 then
terbilang:=terbilang(x div 10)+'puluh'+terbilang(x mod 10)
else if x=100 then
terbilang:='Seratus' else
Writeln('Angka Yang dimasukkan Lebih dari 100');
end;
var
i:longint;
lanjut:char;
begin
repeat
clrscr;
writeln('======================================');
writeln('PROGRAM KONVERSI ANGKA TERBILANG 1-100');
writeln('======================================');
writeln;
writeln('');
write('Masukan Angka = ');readln(i);
writeln('');
write('Terbilang = ',terbilang(i));
writeln('');
writeln;
writeln('Coba Lagi? (Y/T) = ');readln(lanjut);
until (lanjut='t')or(lanjut='T');
end.
soal 3
Program SOAL3;
uses CRT;
Var
A, B, C, X : STRING[20];
Begin
CLRSCR;
A := 'informatika' ;
B := 'si' ;
C := 'Sistem' ;
X := COPY(A,1,7) ;
WRITELN(C,' ',CONCAT(X,B));
REPEAT UNTIL KEYPRESSED;
End.
soal 2
Program Nama;
Uses CRT;
Var
NM : STRING ;
X,Y: INTEGER;
BEGIN
CLRSCR;
NM:= 'M.RIDHO DWI JAYA' ;
WRITELN('PANJANG STRING ','"',NM,'"',' ADALAH ',LENGTH(NM));
WRITELN;
FOR X := 1 TO LENGTH(NM) DO
BEGIN
IF Y = 1 THEN
BEGIN
Y:= X;
END
ELSE
BEGIN
TEXTCOLOR(10);
INC(Y);
END;
WRITE(COPY(NM,X,1));
DELAY(100);
END;
REPEAT UNTIL KEYPRESSED;
END.
soal 1
Program SOAL1;
uses CRT;
var
X , Y ,
KATA : STRING ;
Begin
CLRSCR;
X := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
KATA:= 'FGH' ;
WRITELN(X);
WRITELN;
WRITELN(KATA,' Di Posisi ',POS(KATA,X));
WRITELN;
Y := COPY(X,POS('FGH',X),3);
WRITELN(Y);
READLN;
End .
Tidak ada komentar:
Posting Komentar