INPUT PROGRAM :
tulis:-nl,
write('Nama:'),read(NAMA),nl,
write('Sisi Persegi:'),read(SISI),nl,
LUAS is SISI * SISI,
write('Nama Saya'),write(NAMA),nl,
write('Luas Badan Saya'),write(LUAS),nl,
nl.
OUTPUT PROGRAM :
% d:/DATA KENDAR/KUMPULAN TUGAS S1/PRAKTIKUM SWI-PROLOG/LA dan LP 2/tulis.pl compiled 0.00 sec, 1,080 bytes
Welcome to SWI-Prolog (Multi-threaded, Version 5.4.7)
Copyright (c) 1990-2003 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- tulis.
Nama:sukendar.
Sisi Persegi:12.
Nama Sayasukendar
Luas Badan Saya144
Yes
Program Selanjutnya membuat looping :
loopb(D):-
(D>0,write('*'),
B is D-1,
loopb(B);
D=0).
OUTPUT PROGRAM :
% d:/DATA KENDAR/KUMPULAN TUGAS S1/PRAKTIKUM SWI-PROLOG/LA dan LP 2/loopb.pl compiled 0.00 sec, 788 bytes
Welcome to SWI-Prolog (Multi-threaded, Version 5.4.7)
Copyright (c) 1990-2003 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- loopb(10).
**********
Yes
Masih sama dengan program yang diatas tetapi saya hanya menyisipkan coding nl.
INPUT PROGRAM :
loopb(D):-
(D>0,write('*'),nl,
B is D-1,
loopb(B);
D=0).
OUTPUT PROGRAM :
% d:/DATA KENDAR/KUMPULAN TUGAS S1/PRAKTIKUM SWI-PROLOG/LA dan LP 2/loopb2.pl compiled 0.00 sec, 864 bytes
Welcome to SWI-Prolog (Multi-threaded, Version 5.4.7)
Copyright (c) 1990-2003 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- loopb(10).
*
*
*
*
*
*
*
*
*
*
Yes
PROGRAM SELANJUTNYA MEMBUAT CETAK HURUF BERURUTAN DARI YANG TERBESAR HINGGA TERKECIL :
INPUT PROGRAM :
loopb(D):-
(D>0,write(D),nl,
B is D-1,
loopb(B);
D=0).
OUTPUT PROGRAM :
% d:/DATA KENDAR/KUMPULAN TUGAS S1/PRAKTIKUM SWI-PROLOG/LA dan LP 2/loopb3.pl compiled 0.00 sec, 860 bytes
Welcome to SWI-Prolog (Multi-threaded, Version 5.4.7)
Copyright (c) 1990-2003 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- loopb(10).
10
9
8
7
6
5
4
3
2
1
Yes
PROGRAM SELANJUTNYA MEMBUAT CETAK HURUF BERURUTAN DARI YANG TERKECIL HINGGA TERBESAR :
INPUT PROGRAM :
output_values(B,B):-
write(B),nl,
write('selesai'),nl.
output_values(A,B):-
A=\=B,write(A),nl,
N is A+1,output_values(N,B).
OUTPUT PROGRAM :
% d:/DATA KENDAR/KUMPULAN TUGAS S1/PRAKTIKUM SWI-PROLOG/LA dan LP 2/loopb4.pl compiled 0.00 sec, 948 bytes
Welcome to SWI-Prolog (Multi-threaded, Version 5.4.7)
Copyright (c) 1990-2003 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- output_values(1,10).
1
2
3
4
5
6
7
8
9
10
selesai
SEKIAN