2.Write a Prolog program to implement max(X, Y, M) so that M is the maximum of two numbers X and Y.
% Write a Prolog program to implement max(X, Y, M) so that M is the maximum
of two numbers X and Y.
% below max function is not predefined you can use any name as function
max(X,Y):-
(
X=Y ->
write('Both are Equal');
X>Y ->
( Z is X,
write(Z)
);
X<Y ->
( Z is Y,
write(Z)
)).
% Output
No comments:
Post a Comment