0% found this document useful (0 votes)
35 views2 pages

Artificial Intelligence Lab-Day 2: Code

Uploaded by

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

Artificial Intelligence Lab-Day 2: Code

Uploaded by

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

ARTIFICIAL INTELLIGENCE LAB- DAY 2

1. Write a program in prolog to check whether a number is present within a


specific range or not.

CODE:

range(X,A,B):- X>A, X>B; X>B,X>A.

OUTPUT:

2. Write a program in prolog to find out the minimum number between two
number

CODE:

minimum (A,B) :- A=<B, write(‘Minimum is ’), write(A) .


minimum (A,B) :- A>B, write(‘Minimum is ’), write (B) .

OUTPUT:

3. Write a program in prolog to find out the maximum number between three
numbers.

CODE:
maximum (A,B,C) :- A>=B, A>=C, write (‘Maximum is ’) , write (A).
maximum (A,B,C) :- B>=A, B>=C, write (‘Maximum is ’) , write (B).
maximum (A,B,C) :- C>=A, C>=B, write (‘Maximum is ’) , write (C).

OUTPUT:

4. Write a program in prolog to find out whether a given number is odd or even.

CODE:

even_odd(A) :- A mod 2 =:= 0, write (‘ Number is even ’).


even_odd(A) :- A mod 2 =:= 0, write (‘ Number is even ’).

OUTPUT:

You might also like