Ai 9
Ai 9
9. Write a program in prolog to find the result after division of two numbers.
Knowledge Representation
start:-div.
div:-
write('X='),read(X),
write('Y='),read(Y),
D is X/Y,
write('Result is '),write(D).
Query and Output
9 ?- start.
X=5.
Y=3.
Result is 1.66667
Yes
1 ?- on(block1, table1).
No
2 ?- above(block1, table1).
Yes
3 ?- above(block1, block2).
Yes
4 ?- above(block2, X).
X = table1
Yes
5 ?- above(block3, X).
X = block4
Yes
6 ?- above(X, table1).
X = block2
Yes
7 ?- above(X,Y).
X = block1
Y = block2
Yes
1 3
2 4
__________________________________________________________