Monday, July 17, 2023

10. Write a Prolog program to implement max(X,Y,Max) so that Max is the greater of two numbers X and Y.

 10. Write a Prolog program to implement max(X,Y,Max) so that Max is the greater of two numbers X and Y.


max(X,Y,R):-

 X>=Y ->

  R is X,

  write(R)

 ;

  R is Y,

  write(R).

 

OUTPUT:

max(2,6,X).

6

X = 6



No comments:

Post a Comment