0% found this document useful (0 votes)
7 views5 pages

Lab 4-6

Solution of AI&ES from 4 to 6

Uploaded by

IJLAL HUSSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Lab 4-6

Solution of AI&ES from 4 to 6

Uploaded by

IJLAL HUSSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LAB 4

Q: 1 Write program in prolog to implement all data types you have studied above.
LAB 5
Exercise:
Q: 1. Write a program to implement the following:
likes(fred,cola).
likes(fred,cheap_cigars).
likes(fred,monday_night_football).
likes(sue,jogging). likes(sue,yogurt).
likes(sue,bicycling).
likes(sue,noam_chomsky).
likes(mary,jogging).
likes(mary,yogurt).
likes(mary,bicycling).
likes(mary,george_bush).
Queries:
?- likes(fred,cola).
?- likes(fred,X).
?- likes(fred,X).
?- likes(Y,jogging).
LAB 6
Exercise:
1. Write code in prolog to generate the following output:
5 plus 8 is 13.
X=13
3 multiply by 3 is 9.
X = 9.

ADDITION: -
sum(X,Y):-

S is X+Y,

write(S).

MULTIPLICATION: -
mul(X,Y):-

S is X*Y,

write(S).
Q: 2 Write code in prolog to generate table of any number.

Q: 3 Write code in prolog to print your name and roll no on screen.

say_hi :-

write('What is your name! '),

read(X),

write(X),

write(' Roll Number is : TCT-002 ').

You might also like