Sunday, February 16, 2025

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

 


% 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)
  )
  ;
  (
  Z is Y, 
  write(Z)
  ) 
).
% Output
Prolog Program to find maximum of two numbers.
Prolog Program to find maximum of two numbers.

No comments:

Post a Comment

15. Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list of even or odd length respectively.

  Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list ...