Menu

Artificial Intelligence [ Lab Programs ]


Aim:

Write a program in prolog to implement simple arithmetic

Solution :

% Production rules:

c_to_f
f is c * 9 / 5 + 32
freezing f < = 32

% Rules:

c_to_f(C,F) :-
	F is C * 9 / 5 + 32.

freezing(F) :-
	F =< 32.

Output:

% Queries :

?- c_to_f(100,X).
X = 212
Yes
?- freezing(15).
Yes
?- freezing(45).
No

Related Content :

Artificial Intelligence Lab Programs

1) Write a program in prolog to implement simple facts and Queries View Solution

2) Write a program in prolog to implement simple arithmetic View Solution

3) Write a program in prolog to solve Monkey banana problem View Solution

4) Write a program in prolog to solve Tower of Hanoi View Solution

5) Write a program in prolog to solve 8 Puzzle problems View Solution

6) Write a program in prolog to solve 4-Queens problem View Solution

7) Write a program in prolog to solve Traveling salesman problem View Solution

8) Write a program in prolog for Water jug problem View Solution