max(P,Q):-P>Q,write('Larger number is '),write(P).
max(P,Q):-P<Q,write('Larger number is '),write(Q).
max(P,Q):-P=Q,write('Both are equal ').
output
1 ?- max(2,3).
Larger number is 3
true
2 ?- max(2,1).
Larger number is 2
true .
3 ?- max(2,2).
Both are equal
true.
0 comments:
Post a Comment