PROLOG Assignments
1. Write a prolog program to represent a family tree and write the predicates for different
relationships like father, mother, brother, sister, cousin, grandmother, grandfather etc.
2. Write a prolog program to find the circumference and area of a circle.
3. Write a prolog program to find the ‘N’th Fibonacci term.
4. Write a prolog program to find the Fibonacci series upto N terms.
5. Write a prolog program to compute the factorial of a given number.
6. Write a prolog program to find whether a given number is odd or even.
7. Write a prolog program to determine whether a given number is prime or not.
8. Write a prolog program to find the sum and average of a list of numbers.
9. Write a prolog program to find the minimum and maximum from a list of numbers.
10. Write a prolog program to find the GCD of a list of numbers.
11. Write a prolog program to find whether a number is a member of a list or not.
12. Write a prolog program to find the size of a list.
13. Write a prolog program to find the last element of a list.
14. Write a prolog program to delete the ‘K’th element from a list.
15. Write a prolog program to concatenate two lists.
16. Write a prolog program to insert an element at the Kth position.
17. Write a prolog program to determine whether an input string is accepted by the DFA
constructed from the regular expression: c(a|b)*d+
18. Write a prolog program to determine whether an input string is accepted by the DFA
constructed from the regular expression: (a|b)+(cd)*e
19. Write a prolog program to implement two-input XOR gate using two-input NAND gates only.
20. Write a prolog program to represent a digital circuit to find an output.
21. Write a prolog program to sort a given list using merge sort.
22. Write a prolog program to sort a given list using insertion sort.
23. Write a prolog program to reverse a list. Also determine whether a given list is palindrome or
not.
24. Write a prolog program to find the union, intersection and set difference of two lists of elements.
25. Write a prolog program to generate all permutations of a list of elements.
26. Write a prolog program to eliminate the duplicate elements of a list. The output list should
contain the unique elements.
27. Write a prolog program to generate all integers in a given range.
28. Write a prolog program to generate a binary tree and write predicates for the following: path,
leaf, root, sibling, height, level.
29. Write a prolog program to generate the nodes traversed in preorder, postorder and inorder
traversals.
30. Write a prolog program to count the number of vowels in a list of characters (word).