Monday, July 17, 2023

2. Write a prolog program to find the maximum of two numbers.

 2. Write a prolog program to find the maximum of two numbers.


max(X,Y):-(   X=Y ->write('both are equal') ;

 X>Y ->  (  Z is X,   write(Z), write('  is max')  )

  ;

  (  Z is Y,   write(Z),write(' is max')  ) ).


OUTPUT:

max(50,50).

both are equal

1true

max(50,5).

50is max

1true


No comments:

Post a Comment