Question

Write a Prolog rule to find the minimum of three numbers. Then, write a sample query...

Write a Prolog rule to find the minimum of three numbers. Then, write a sample query to find the minimum of 15, 12 and 22. Prolog syntax.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

maximum:-write('Input first number'),nl, read(Number1),nl,write('Input second number'),
nl,read(Number2),nl,write('Input third number'),nl,read(Number3),
find_max(Number1,Number2,Number3),find_min(Number1,Number2,Number3).
find_max(Number1,Number2,Number3):-(Number1>Number2,Number1>Number3->nl,write(Number1),write(' is the biggest'),!);
(Number2>Number3->nl,write(Number2),write(' is the biggest'),!);nl,write(Number3),
write(' is the biggest'),!

find_min(Number1,Number2,Number3):-(Number1<Number2,Number1<Number3->nl,write(Number1),write(' is the smallest'),!);
(Number2<Number3->nl,write(Number2),write(' is the smallest'),!);nl,write(Number3),
write(' is the smallest'),!

DON'T FORGET TO LIKE.

THANKS BY HEART.

.

Add a comment
Know the answer?
Add Answer to:
Write a Prolog rule to find the minimum of three numbers. Then, write a sample query...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT